Issue
I was trying the code from this URL http://afewdoubts.blogspot.com/2013/03/upload-fileimage-in-folder-using-servlet.html but it saves the images to NetBeans temporary folder C:\Users\user\AppData\Roaming\NetBeans\8.1\config\GF_4.1.1\domain1\generated\jsp\WebApplication
instead of saving it to the path specified.
Heres the code I've tried editing
PrintWriter out = response.getWriter();
classclass c=new classclass();
String savePath = File.separator + SAVE_DIR;
File fileSaveDir=new File(savePath);
String firstName=request.getParameter("firstname");
String lastName=request.getParameter("lastname");
Part part=request.getPart("file");
String fileName=extractFileName(part);
/*if you may have more than one files with same name then you can calculate some random characters and append that characters in fileName so that it will make your each image name identical.*/
part.write(savePath + File.separator + fileName);
Your help is appreciated. Thanks
Solution
This code works fine but the file get saved in the glassfish temporary folder. Help me with this if you can File uploads using NetBeans and GlassFish Server
Conclusion: There's nothing wrong with the code but the glassfish server or netbeans configuration.
Answered By - Paddler
Answer Checked By - Marilyn (JavaFixing Volunteer)