If these questions are asked on the main list,
others can learn too?

 

    -----Original Message-----
    From: Caroline Jen 
    
    I am trying to upload files from clients machine.   
 

    I understand that we must specify METHOD=post and 
    ENCTYPE="multipart/form-data" in the <FORM> tag.
    
    Would you please help me with a number of questions:
    
    1. Once the client makes a selection from his/her PC, the 
    file name will appear in the text field.  How do I 'save 
    the file name'?  
within the servlet, 

        DiskFileUpload upload = new DiskFileUpload();
        boolean isMultipart = FileUpload.isMultipartContent(request);
        if (!isMultipart) {
            logger.warn(userName(request)+"File upload is not multipart");
            ULerr = FORMNOTMULTIPART;
        }
        // Set upload parameters
    ...
        try {
            java.util.List items = upload.parseRequest(request);
            // Process the uploaded items
            String [] parms = gParms (items, request);
            String [] gfileList = gFiles (items, request);

I have some plain textboxes as well as the list of files.
I'm re-working this piece;
 currently

   /**
     *unwrap filelist, return as string array.
     **/
    public String [] gFiles(java.util.List items,HttpServletRequest request){
        String[] retval=null;
        java.util.Iterator iter = items.iterator();
        int pos=0;
        while (iter.hasNext()) {
            FileItem item = (FileItem) iter.next();
            if (!item.isFormField()) {
                String fieldName = item.getFieldName();
                String fileName = item.getName();
                String contentType = item.getContentType();
                boolean isInMemory = item.isInMemory();
                long sizeInBytes = item.getSize();
                if (sizeInBytes == 0){
                    logger.info(userName(request)+" No files selected");
                    out.println("<li>No files selected</li>");
                }else{ // file OK
                pos +=1;
                retval[pos] = fileName; // full path and filename
                }
            }//end of if is Form field
        }// end of while more items

        return retval;

    }// end of gfiles()

That collects the list of filenames, prior to uploading them?
  That should be sufficient to get you started.
The rest of my code is messed with the functionality I need?

HTH DaveP.








    
    2. Do I save what I download from the
    http://www.htmlhelp.com/reference/html40/forms/input.html
    
    in my $TOMCAT/common/lib directory?  Do I have to save it 
    in my $TOMCAT/webapps/AppName/WEB-INF/lib
    directory.

No, its just java once you have the filenames. Just write them whereever you need them 
to be.


    
    3. Are there anything else I have to do to make file uploading work?

Patience :-)    
    
    HTH DaveP.
Shout again if I can help.

-- 
DISCLAIMER:

NOTICE: The information contained in this email and any attachments is 
confidential and may be privileged.  If you are not the intended 
recipient you should not use, disclose, distribute or copy any of the 
content of it or of any attachment; you are requested to notify the 
sender immediately of your receipt of the email and then to delete it 
and any attachments from your system.

RNIB endeavours to ensure that emails and any attachments generated by
its staff are free from viruses or other contaminants.  However, it 
cannot accept any responsibility for any  such which are transmitted.
We therefore recommend you scan all attachments.

Please note that the statements and views expressed in this email and 
any attachments are those of the author and do not necessarily represent
those of RNIB.

RNIB Registered Charity Number: 226227

Website: http://www.rnib.org.uk




---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to