JSP Examples
Steps to Execute Jsp |
Module 1 |
Module 2 |
Module 3 |
|
|
| JSP: FileUpload
|
| Step 1: Here is the code Upload your (FileUpload.html) File
|
<html>
<body>
<form action="FileUpload.jsp" method="POST" enctype="multi-part/form-data">
<font color=00f00 size="5">Select your File: <input type="file" name="file"><br>
</font>
<pre> <input type="submit"></pre>
</form>
</body>
</html>
|

|
| Step 2: Here is the code(FileUpload.jsp)write the Data to demo.txt |
<%@ page import="java.io.*;"%>
<html>
<body>
<%
String filename=request.getParameter("file");
FileInputStream is=new FileInputStream(filename);
FileOutputStream os=new FileOutputStream("c:\\demo.txt");
int ch;
while((ch=is.read())>=0)
os.write(ch);
is.close();
os.close();
out.println("<center><font color=orange size=5>Your File Uploaded is Successfully</font>
</center>");
%>
</body>
</html>
|
 |
| Step 3: Go To and Check The "c:\\demo.txt" directory to your Uploaded file |
|
Back to Top |