You could try doing a String.lastIndexOf( File.pathSeperatorChar ) to get the last occurrence of the separator, and then do a substr using that index to get the file name itself.
james -----Original Message----- From: Schalk Neethling [mailto:[EMAIL PROTECTED] Sent: Thursday, June 09, 2005 3:07 PM To: Jakarta Commons Users List Subject: Re: [fileUpload] Question about file name Martin Thanks for the reply. Do you have a suggestion as to better code to handle getting the filename? I have used both a StringTokenizer as well as String.split but was not able to get to just the filename. Any suggestions or pointers? Thank you! Martin Cooper wrote: >On 6/9/05, Schalk Neethling <[EMAIL PROTECTED]> wrote: > > >>Hey there everyone! >> >>Hope someone can give me an answer here. I am using the fileUpload >>package in one of my apps and have had some trouble getting the actual >>file name when the user is using IE. In IE the entire location string >>is sent by the browser instead of just the file name. Now, I have >>found a way to get past that, I thought, but now here is my problem. >> >>When testing the app on my local WindowsXP machine on both Firefox and >>IE it works perfectly, however, when I move this up to the server, Red >>Hat Linux, the file name written to disk when using IE is completely >>wrong. >> >>Here is the code I use to get the file name: >>if(item.getFieldName().equals("uploadPDF")) { >> >>File fullFile = new File(item.getName()); >>uploadPDF = fullFile.getName(); >>File savedFile = new File(serverFolder, uploadPDF); >>item.write(savedFile); } >> >>Any idea why this would return the file name differently depending on >>which platform the app runs. BTW, the files are uploaded using a >>WindowsXP machine and IE 6.0 as the client. Any ideas? Thanks! >> >> > >I suspect that it's not the platform so much as the JVM. My guess is >that the File implementation on the JVM you're using on Red Hat is not >parsing the Windows path that's provided by IE as you are expecting it >to. You are assuming that File will parse both Windows and Unix paths. >I believe this is true on Sun JVMs, but not on some Linux JVMs. > >-- >Martin Cooper > > > > >>-- >>Kind Regards >>Schalk Neethling >>Web Developer.Designer.Programmer.President >>Volume4.Business.Solution.Developers >>emotionalize.conceptualize.visualize.realize >>Landlines >>Tel: +27125468436 >>Fax: +27125468436 >>Web >>email:[EMAIL PROTECTED] >>Global: www.volume4.com >>Messenger >>Yahoo!: v_olume4 >>AOL: v0lume4 >>MSN: [EMAIL PROTECTED] >> >>We support OpenSource >>Get Firefox!- The browser reloaded - >>http://www.mozilla.org/products/firefox/ >> >>This message contains information that is considered to be sensitive >>or confidential and may not be forwarded or disclosed to any other >>party without the permission of the sender. If you received this >>message in error, please notify me immediately so that I can correct >>and delete the original email. Thank you. >> >> >> >>--------------------------------------------------------------------- >>To unsubscribe, e-mail: [EMAIL PROTECTED] >>For additional commands, e-mail: [EMAIL PROTECTED] >> >> >> >> > >--------------------------------------------------------------------- >To unsubscribe, e-mail: [EMAIL PROTECTED] >For additional commands, e-mail: [EMAIL PROTECTED] > > > > > > -- Kind Regards Schalk Neethling Web Developer.Designer.Programmer.President Volume4.Business.Solution.Developers emotionalize.conceptualize.visualize.realize Landlines Tel: +27125468436 Fax: +27125468436 Web email:[EMAIL PROTECTED] Global: www.volume4.com Messenger Yahoo!: v_olume4 AOL: v0lume4 MSN: [EMAIL PROTECTED] We support OpenSource Get Firefox!- The browser reloaded - http://www.mozilla.org/products/firefox/ This message contains information that is considered to be sensitive or confidential and may not be forwarded or disclosed to any other party without the permission of the sender. If you received this message in error, please notify me immediately so that I can correct and delete the original email. Thank you. --------------------------------------------------------------------- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] --------------------------------------------------------------------- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
