ajax jquery post图片流给服务器进行图片上传

ajax 图片上传,ajax来post图片流给服务器。

FormData 可以把post数据改成流传输。

 <form id="frm">
  <div id="box2" style="margin:0px auto; width:100%; min-height:150px; background:#FF9">
    <input type="file" name="file1" id="file1" />
    <input type="button" value="上传" id="upload">
</form>
 
//ajax 上传
$("#upload").click(function(){
    var url =  "http://mm.com/ajaxupload.php";
 
    var formData = new FormData($( "#frm" )[0]);  
     $.ajax({  
          url: url,  
          type: 'POST',  
          data: formData,  
          async: false,  
          cache: false,  
          contentType: false,  
          processData: false,  
          success: function (returndata) {  
            var jsonObj = eval('('+returndata+')');
 
              //alert(jsonObj.f);  
              //$("#idCardFront").val(jsonObj.f);
             //$("#idCardBack").val(jsonObj.b);
 
          },  
          error: function (returndata) {  
              alert(returndata);  
          }  
     }); 
});


This entry was posted in PHP, WEB前端 and tagged , , . Bookmark the permalink.
月小升QQ 2651044202, 技术交流QQ群 178491360
首发地址:月小升博客https://java-er.com/blog/ajax-post-jquery/
无特殊说明,文章均为月小升原创,欢迎转载,转载请注明本文地址,谢谢
您的评论是我写作的动力

Leave a Reply

Your email address will not be published. Required fields are marked *

*

*

  

  

About Me

静水流深,水滴石穿