2013-04-17 3 views
1

텍스트 파일을 클라이언트 컴퓨터에서 서버로 업로드하려고합니다. 아래는 jsp에서 사용하고있는 코드입니다. 내가 부하 파일의 내용 유형을 확인했다jsp로 텍스트 파일을 업로드하는 방법

<tr> 
      <td class="FORMLABEL" nowrap valign=middle> 
       &nbsp;&nbsp;<%= fileLabel %>&nbsp; 
      </td> 
      <td class="FORMELEMENT" nowrap valign=middle> 
       <input size = "50" name="loadFile" type="FILE" > 
      </td> 
    </tr> 

, 그것은 응용 프로그램/x-www-form-urlencoded를 내가 파일을 읽을 필요가 입니다. 이 파일을 클라이언트 컴퓨터에서 서버에 JSP를 사용하여 복사하는 방법은 무엇입니까?

답변

0

당신은

protected void doPost(HttpServletRequest request, HttpServletResponse response) 
        throws ServletException, IOException { 
    try { 

--- - - - 

----- 

How to upload files to server using JSP/Servlet?

} 
에 표시된 것처럼이 양식을 작성 fileupload

위한 서블릿을 작성하고 서버

<form action="upload" method="post" enctype="multipart/form-data"> 
    <input type="text" name="description" /> 
    <input type="file" name="file" /> 
    <input type="submit" /> 
</form> 

와 서블릿에 제출해야 자세한 내용은

this을 참조하십시오.

관련 문제