users@glassfish.java.net

Re: pls help, file upload to a local directory

From: <glassfish_at_javadesktop.org>
Date: Thu, 19 Apr 2007 07:32:15 PDT

Hi,

Why r you use Jakarata FileUpload ?
You can use java and save file from client to Server easily.
I am sending some codes to u .

<!-- upload.jsp -->

<%

String contentType = request.getContentType();
System.out.println("Content type is :: " +contentType);
if ((contentType != null) && (contentType.indexOf("multipart/form-data") >= 0)) {
DataInputStream in = new DataInputStream(request.getInputStream());
int formDataLength = request.getContentLength();

byte dataBytes[] = new byte[formDataLength];
int byteRead = 0;
int totalBytesRead = 0;
while (totalBytesRead < formDataLength) {
byteRead = in.read(dataBytes, totalBytesRead, formDataLength);
totalBytesRead += byteRead;



You can use these code to your JSP.
If you have any problem, mail me at m.sudan21_at_gmail.com
[Message sent by forum member 'madhu_sud' (madhu_sud)]

http://forums.java.net/jive/thread.jspa?messageID=213191