Blogger Information
Blog 91
fans 2
comment 4
visits 127873
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
h5上传图片
夏日的烈风的博客
Original
1889 people have browsed it

<img style="display: none" id="upload_org_code_img" src="" width="150" height="150">
<input type="file" id="user">
<input id="file_upload_image" name="thumb" type="hidden" value="">



$('#user').change(function () {
   var files = document.getElementById('user').files[0]
   var formData = new FormData();
   formData.append("file", files)
   console.log(formData)
   $.ajax({
       type: "post",
       url: "{:url('api/image/upload')}",
       contentType: false,
       processData: false,
       data: formData,
       async: false,
       dataType: 'json',
       success: function (res) {
           if (res.code == 1) {
               $("#upload_org_code_img").attr("src", res.data);
               $("#file_upload_image").attr("value", res.data);
               $("#upload_org_code_img").show();
               $(".img-circle").hide()
           }else {
               layer.msg(res.msg)
           }
       }
   })
})

Statement of this Website
The copyright of this blog article belongs to the blogger. Please specify the address when reprinting! If there is any infringement or violation of the law, please contact admin@php.cn Report processing!
All comments Speak rationally on civilized internet, please comply with News Comment Service Agreement
0 comments
Author's latest blog post