Thanks Martin

Martin Cooper wrote:

On 6/9/05, William Noto <[EMAIL PROTECTED]> wrote:
Won't you still have an OS dependency in there with that \\?

Yes, it would be OS dependent. However, IE is the only browser (that
I'm aware of) that sends the full path, so that probably doesn't
matter. (Not sure what IE on Mac does, but it's broken in plenty of
other ways too.)

I think you can use File.pathSeperatorChar to handle that.

Nope. If the upload came from a Windows system and the server is
running on *nix, then the system separator is *not* what you want.
You'd be looking for '/' in a path that uses '\' as the separator.

--
Martin Cooper


William B. Noto    Open Finance    71 Gansevoort Street, Suite 2D, New York,
NY 10014
Tel  + 1 646 230 8666     Fax  + 1 646 230 8657    [EMAIL PROTECTED]


-----Original Message-----
From: Schalk Neethling [mailto:[EMAIL PROTECTED]
Sent: Thursday, June 09, 2005 3:48 PM
To: Martin Cooper
Cc: Jakarta Commons Users List
Subject: Re: [fileUpload] Question about file name

If anyone experiences this same problem here is the solution:

Instead of:

File fullFile  = new File(item.getName());
uploadPDF = fullFile.getName();
File savedFile = new File(serverFolder, uploadPDF);
item.write(savedFile);

Use:

int i = item.getName().lastIndexOf('\\');
uploadPDF = item.getName().substring(i+1);
File savedFile = new File(serverFolder, item.getName().substring(i+1) );
item.write(savedFile);



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]







--
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]








--
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]

Reply via email to