php - How to use Ajax file upload with other inputs? -


i using php , codeigniter, want build form several inputs , file uploader. file uploaded before submitting form or refeshing it. tried ajax multi file upload in codeigniter in order upload file form must submitted. don't know how use other inputs , submitting form after filling fields , uploading files

you have use formdata in order send files , other input both together.see below example more reference

$("#add_product").click(function(e){     e.preventdefault();     var fdata = new formdata()      fdata.append("product_name",$("product_name").val());      if($("#file")[0].files.length>0)        fdata.append("file",$("#file")[0].files[0])      $.ajax({         type: 'post',         url: 'ajax.php',         data:fdata,         contenttype: false,         processdata: false,          success: function(response)         {             alert(response);         }     }) }); 

Comments

Popular posts from this blog

PHP and MySQL WP -

android - InAppBilling registering BroadcastReceiver in AndroidManifest -

go - golang pprof for c library code -