java - jquery FormData not working with Servlet -


this question has answer here:

i sending 1 file tomcat server using jquery formdata. file being received on server other value send file not being received. processing file upload, using http://commons.apache.org/proper/commons-fileupload/ , http://commons.apache.org/io/. getting file somehow. when write

request.getparameter("file") 

in servlet below code, returns null. doesn't show parameter in request object. don't understand how gets file then. can me solve this?

$('#uploadcoursedetail').click(function() {     var form_data = new formdata();     if (!($('#coursedetails').prop('files')[0] == undefined)) {         var file_data = $('#coursedetails').prop('files')[0];         form_data.append('file', 'examdetail');         form_data.append('coursedetails', file_data);     }     $.ajax({         url: 'exam_timetable_scheduler_byslots_web_project/fileuploadservlet',         type: 'post',         contenttype: false,         processdata: false,         cache: false,         data: form_data,         success: function(data) {             alert("file uploaded !");         }     }); }); 

i use firebug track requests. shows both fields being sent server. below snapshot same:enter image description here

there mistake in backend code. above code works perfectly. sincere apologies wrong post!


Comments

Popular posts from this blog

inversion of control - Autofac named registration constructor injection -

verilog - Systemverilog dynamic casting issues -

ios - Change Storyboard View using Seague -