Hello!

I am using MultipartParser to upload files.
The codes compiles successfully.
But when I run it, I find that the uploaded file is empty.
Please see my code below and comment.

Thanks.
Deepa



                MultipartParser mp = new MultipartParser(env.req, 10*1024*1024);
                Part part;
                String path = null;
                FilePart filePart = null;
                String fileName = null;

                while ((part = mp.readNextPart()) != null) {
                        String name = part.getName();
                        if (part.isParam()) {
                                ParamPart paramPart = (ParamPart) part;
                                if (name.equals("path")){
                                        path = paramPart.getStringValue();
                                }
                        } else if (part.isFile()) {
                                filePart = (FilePart) part;
                                fileName = filePart.getFileName();
                        }
                }
                File uploadDir = new 
File("/home/www/dramamurthy/sitebuilder/WEB-INF/Uploads/");
                if (!uploadDir.exists()) {
                        uploadDir.mkdir();
                }

                if (fileName != null) {
                        long size = filePart.writeTo(uploadDir);
                }

___________________________________________________________________________
To unsubscribe, send email to [EMAIL PROTECTED] and include in the body
of the message "signoff SERVLET-INTEREST".

Archives: http://archives.java.sun.com/archives/servlet-interest.html
Resources: http://java.sun.com/products/servlet/external-resources.html
LISTSERV Help: http://www.lsoft.com/manuals/user/user.html

Reply via email to