javascript - AJAX controller not looping through each file and saving in location. Only doing the first file upload -


my below code uploading first file in array path location. can see wrong server side controller:

private static string uploaded_folder = "c://temp//";  @requestmapping(value = { "/fileupload" }, method = requestmethod.post) @responsebody public string uploadfile( @requestparam("number") string number, @requestparam("files[]") multipartfile[] files, multiparthttpservletrequest req, httpservletresponse res) {             (multipartfile file : files) {      try {         file directory = new file(uploaded_folder + number);         logger.info(directory.tostring());                 if (! directory.exists()){                     directory.mkdir();                     logger.info("directory created");                   }             byte[] bytes = file.getbytes();             logger.info(bytes.tostring());             path path = paths.get(uploaded_folder + number + "//" + file.getoriginalfilename());             logger.info(path.tostring());             files.write(path, bytes);             logger.info("you have uploaded '" + file.getoriginalfilename() + "'");             return("file uploaded");       } catch (exception e) {         res.setstatus(httpservletresponse.sc_internal_server_error);         logger.error("failed upload file '" + file.getoriginalfilename() + "'", e);         return("file not uploaded");     } }     return "redirect:/fileupload"; }  } 

return("file uploaded"); 

this breaks out of loop.

you need put return after loop ends if want run completely.


Comments

Popular posts from this blog

php - Permission denied. Laravel linux server -

google bigquery - Delta between query execution time and Java query call to finish -

python - Pandas two dataframes multiplication? -