Solved

Upload 5 MB file from a JSP to UNIX box

Posted on 2004-10-01
3
299 Views
Last Modified: 2010-04-01
Hi,

I want to upload a file from a JSP page and put it into a location onto the remote UNIX box.My applcation is deployed in the UNIX box only.

I'd prefer to use only those APIs provided by sun,and not any third party tools.Thanks

Please usggest.
0
Comment
Question by:vishrutsumit
3 Comments
 

Accepted Solution

by:
kheefatt earned 125 total points
ID: 12206107
You can use the MultipartRequest class written by Jason Hunter. Download the jar at http://www.servlets.com/cos/cos-05Nov2002.zip. Extract it and you'll get a filename cosjar.

There is lots of documentation on how to use these classes here:  
http://www.servlets.com/cos/index.html

Put cos.jar in your <application>\WEB-INF\lib\

1) Create an HTML form with upload button. Name it "upload.html":

<html>
<body>
<form action="uploadResult.jsp" method="post" enctype="multipart/form-data">
<input type="file" name=testfile>
<input type=submit>
</form>
</body>
</html>

2) Create another file called "uploadResult.jsp". Inside the file, put :

<%@ page import="com.oreilly.servlet.*" %>
<%
       MultipartRequest(request, "/home/screen/uploads/",10*1000000);
       out.write("Upload Successful");
%>

3) Before u run, create a directory called uploads. As for my case, screen is my login name and I created a directory called uploads under screen. 10*1000000 is where I limit my upload filesize to 10 mb only.

4) Run it and the file should be uploaded into the directory. This work under my UNIX box!

GOOD LUCK!
0

Featured Post

Highfive + Dolby Voice = No More Audio Complaints!

Poor audio quality is one of the top reasons people don’t use video conferencing. Get the crispest, clearest audio powered by Dolby Voice in every meeting. Highfive and Dolby Voice deliver the best video conferencing and audio experience for every meeting and every room.

Join & Write a Comment

Find out what Office 365 Transport Rules are, how they work and their limitations managing Office 365 signatures.
A safe way to clean winsxs folder from your windows server 2008 R2 editions
Here's a very brief overview of the methods PRTG Network Monitor (https://www.paessler.com/prtg) offers for monitoring bandwidth, to help you decide which methods you´d like to investigate in more detail.  The methods are covered in more detail in o…
This tutorial demonstrates a quick way of adding group price to multiple Magento products.

706 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

17 Experts available now in Live!

Get 1:1 Help Now