commons-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Schalk" <sch...@volume4.co.za>
Subject RE: fileupload name issue
Date Mon, 25 Aug 2003 15:14:08 GMT
Harshad

I use the bit of code below to get only the file name:

fileName = item.getName();            
            fileFieldName = item.getFieldName();              
            
            StringTokenizer tokenizer = new StringTokenizer(fileName, "\\,
:, /");            
            int amount = tokenizer.countTokens();             
            for (int i = 0; i < amount -1; i++) {
                tokenizer.nextToken();        
            }               
            String currentFile = tokenizer.nextToken();

Kind Regards
Schalk Neethling
Volume4.Development.Multimedia.Branding
emotionalize.conceptualize.visualize.realize
Tel: +27125468436
Fax: +27125468436
email:schalk@volume4.co.za
web: www.volume4.co.za
 

:: -----Original Message-----
:: From: Robert Priest [mailto:Robert.Priest@bentley.com]
:: Sent: Monday, August 25, 2003 5:03 PM
:: To: 'Jakarta Commons Users List'
:: Subject: RE: fileupload name issue
:: 
:: Try fi.getFieldName().
:: 
:: -----Original Message-----
:: From: Harshad Oak [mailto:harshadoak@hotpop.com]
:: Sent: Monday, August 25, 2003 7:03 AM
:: To: commons-user@jakarta.apache.org
:: Subject: fileupload name issue
:: 
:: 
:: Hello,
:: 
:: I am trying to use the FileUpload 1.0 component to upload three files
from
:: an HTML page. I am submitting an HTML form to a JSP page.
:: 
:: The HTML is as follows:
::     <FORM name="filesForm" action="ProcessFileUpload.jsp"
::     method="post" enctype="multipart/form-data">
::         File 1:<input type="file" name="file1"/><br/>
::         File 2:<input type="file" name="file2"/><br/>
::         File 3:<input type="file" name="file3"/><br/>
::         <input type="submit" name="Submit" value="Upload Files"/>
::     </FORM>
:: 
:: In the JSP I have a statement (fi is a reference to
:: org.apache.commons.fileupload.FileItem):
:: 
::     System.out.println("NAME: "+fi.getName());
:: 
:: Strangely enough, if I submit the form using Opera browser version 7.11,
the
:: output of the System.out in the JSP is just the <fileName>. However on
:: trying to submit it using Internet Explorer 5.5, the output is the entire
:: path eg: D:/<directoryname>/<filename>
:: 
:: Is this a known issue and what is the solution for it? I just need the
name
:: and not the entire path to the file. I found a possible workaround in an
:: onjava.com article. However if this bug has been fixed in the latest CVS
:: copy, I could pick that up.
:: 
:: thanks,
:: harshad
:: 
:: ---------------------------------------------------------------------
:: To unsubscribe, e-mail: commons-user-unsubscribe@jakarta.apache.org
:: For additional commands, e-mail: commons-user-help@jakarta.apache.org



Mime
View raw message