2017-05-04 2 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을 사용하여 폴더에 저장

은 Heres는 코드 나는 당신의 도움이 감사

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

편집을 시도했습니다. 감사합니다

답변

0

이 코드는 제대로 작동하지만 파일은 glassfish 임시 폴더에 저장됩니다. 할 수 있으면 이걸로 도와주세요 File uploads using NetBeans and GlassFish Server

결론 : 글래스 피쉬 서버 나 netbeans 설정에는 아무런 문제가 없습니다.

관련 문제