javascript - can't get any file data, It shows file data empty -


this question has answer here:

i did uploading files via ajax. can't file data. shows file data empty.

here ajax part.

    $("#personal_image").on('click',function(event) {         event.preventdefault();         var datastring = $("#personal_image").serialize();          console.log(datastring);          $.ajax({             type: "post",             url: location.origin+"/user/parsonal_image_submit/",             secureuri       :false,             fileelementid   :'user_image',             data: datastring,             datatype: "json",             success: function(data) {                 //success               },             error: function() {                 //error             }         });     }) 

check below code. hope work you. please use on form submit rather using on click.

$('#your_form_id').on('submit',function(e){  	e.preventdefault();  	var formdata = new formdata($(this)[0]);  	var url = $('#personal_image').attr('action');  	$.ajax({  		url: url,  		type: 'post',  		data: formdata,  		datatype: 'json',  		processdata: false,  		contenttype: false,  		//async: false,  		success: function(data){  			//success  		}  	});  });


Comments

Popular posts from this blog

resizing Telegram inline keyboard -

command line - How can a Python program background itself? -

php - "cURL error 28: Resolving timed out" on Wordpress on Azure App Service on Linux -