2017-05-04 96 views
0

我在尝试使用此URL的代码http://afewdoubts.blogspot.com/2013/03/upload-fileimage-in-folder-using-servlet.html,但它将图像保存到NetBeans临时文件夹C:\Users\user\AppData\Roaming\NetBeans\8.1\config\GF_4.1.1\domain1\generated\jsp\WebApplication而不是将其保存到指定的路径。上传图像并使用JSP/Servlet将其保存到文件夹中

继承人的代码,我已经试过编辑

  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); 

您的帮助表示赞赏。 感谢

回答

相关问题