Friday, August 21, 2009

Upload a file to a server-Java Source Code [JSP]



The below code will give you the idea how to upload a file to a server location. We are using a specific folder “uploadedFile” in the server current directory for the uploaded files.

To implement upload functionality, we will be using FileUpload and IO packages under common packages of Apache. This will ease out our job of coding this.

Links to download the jar files for the above.

http://commons.apache.org/fileupload/
http://commons.apache.org/io/

We will be creating two JSPs one of which will be the first page which will be asking for the files to browse and upload. After submitting the file, it will give us the details of the file which we have uploaded.

Below are the sample JSPs:
uploadfileToServer.jsp



fileUpload.jsp

















No comments:

Total Pageviews