Solved

Upload 5 MB file from a JSP to UNIX box

Posted on 2004-10-01
3
300 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

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Some code to ensure data integrity when using macros within Excel. Also included code that helps secure your data within an Excel workbook.
In 2017, ransomware will become so virulent and widespread that if you aren’t a victim yourself, you will know someone who is.
This Micro Tutorial demonstrates using Microsoft Excel pivot tables, how to reverse engineer competitors' marketing strategies through backlinks.
Migrating to Microsoft Office 365 is becoming increasingly popular for organizations both large and small. If you have made the leap to Microsoft’s cloud platform, you know that you will need to create a corporate email signature for your Office 365…

863 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

22 Experts available now in Live!

Get 1:1 Help Now