Saturday, 19 August 2017

How to Uploading file to the server using JSP

How to Uploading file to the server using JSP

Example of File Upload in JSP
index.jsp
To upload the file to the server, there are two requirements:
You must use the post request.
encodeType should be multipart/form-data that gives information to the server that you are going to upload the file.

<form action="upload.jsp" method="post" enctype="multipart/form-data">
Select File:<input type="file" name="fname"/><br/>
<input type="image" src="MainUpload.png"/>
</form>

upload.jsp
We are uploading the incoming file to the location d:/new, you can specify your location here.

<%@ page import="com.oreilly.servlet.MultipartRequest" %>
<%
MultipartRequest m = new MultipartRequest(request, "d:/new");
out.print("successfully uploaded");

%>

Post a Comment

Whatsapp Button works on Mobile Device only

Start typing and press Enter to search