ajax - File upload/download servlet code from reactjs -


am getting "ismultipart" false while pushing file ajax servlet. me out on file upload/download functionality. writting ajax in reactjs.

ajax call request file upload api :

upload(data) {   ajax({     url: 'api/uploaddocservlet',     data: data,     enctype: 'multipart/form-data',     cache: false,     processdata: false,     contenttype: false,     method:'post',   }, (data) => {     console.log("print data::::"+data);     if (data.error == null) {       this.search({});     } else {       alert(data.error);     }   });  } 

servlet code file upload :

boolean ismultipart = servletfileupload.ismultipartcontent(request); // process if multipart content if (ismultipart) {   // create factory disk-based file items   fileitemfactory factory = new diskfileitemfactory();   // create new file upload handler   servletfileupload upload = new servletfileupload(factory);   try {     system.out.println("uploaddocservlet:::" + upload.parserequest(request));     list<fileitem> multiparts = upload.parserequest(request);     (fileitem item : multiparts) {       if (!item.isformfield()) {         string name = new file(item.getname()).getname();         object result = service.uploaddoc(name);         //item.write(new file(upload_directory + file.separator + name));       }     }   } } 


Comments

Popular posts from this blog

android - InAppBilling registering BroadcastReceiver in AndroidManifest -

python Tkinter Capturing keyboard events save as one single string -

sql server - Why does Linq-to-SQL add unnecessary COUNT()? -