javascript - asynchoronous file upload not working -


i have function called make progress called button upload. function below:

<button type="button" id = "upload" onclick="makeprogress()" class="btn btn-default" disabled>upload</button>   function makeprogress(){                   var formdata = new formdata();       formdata.append('file', $('input[type=file]')[0].files[0]);       console.log("form data " + formdata);       $.ajax({           url : '/fileupload',           data : formdata,           processdata : false,           contenttype : false,           type : 'post',           success : function(data) {               alert(data);           },           error : function(err) {               alert(err);           }      });          } 

controller.java file:

@requestmapping(value = { "/fileupload" }, method = requestmethod.post) @responsebody public integer uploadfile(         httpservletrequest req, httpservletresponse res) {     try {          logger.info("file uploaded");          return 0;     } catch (exception e) {         res.setstatus(httpservletresponse.sc_internal_server_error);         return 1;     } } 

}

when running locally error 404 on file upload


Comments

Popular posts from this blog

commonjs - How to write a typescript definition file for a node module that exports a function? -

openid - Okta: Failed to get authorization code through API call -

ios - Change Storyboard View using Seague -