users@glassfish.java.net

Re: pls help, file upload to a local directory

From: <glassfish_at_javadesktop.org>
Date: Thu, 19 Apr 2007 09:38:47 PDT

hi, i'm giving this a try as well... and let you know how it goes


> 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 'arckjmaster' (arckjmaster)]

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