You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@commons.apache.org by Schalk Neethling <sc...@volume4.com> on 2005/06/09 19:56:29 UTC
[fileUpload] Question about file name
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!
--
Kind Regards
Schalk Neethling
Web Developer.Designer.Programmer.President
Volume4.Business.Solution.Developers
emotionalize.conceptualize.visualize.realize
Landlines
Tel: +27125468436
Fax: +27125468436
Web
email:schalk@volume4.com
Global: www.volume4.com
Messenger
Yahoo!: v_olume4
AOL: v0lume4
MSN: volume4_@hotmail.com
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: commons-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: commons-user-help@jakarta.apache.org
Re: [fileUpload] Question about file name
Posted by Schalk Neethling <sc...@volume4.com>.
I will definitely try this out, thank you.
Dakota Jack wrote:
>Yup:
>
>Frank,
>
>If the File class does not normalize the string used to create the
>File, then there is a bug. There seems to be a bug in one version of
>Linux and that has been reported to Sun. The constructor for File is
>as follows:
>
>
> public File(String pathname) {
> if (pathname == null) {
> throw new NullPointerException();
> }
> this.path = fs.normalize(pathname);
> this.prefixLength = fs.prefixLength(this.path);
> }
>
>Notice that an object fs is called to normalize the pathname. The
>object fs is created as a static field in all File classes as follows:
>
>
> static private FileSystem fs = FileSystem.getFileSystem();
>
>The FileSystem class is an abstract class that has to be implemented,
>of course, for the os on which it exists. So, the basis for the class
>is a JNI method:
>
> public static native FileSystem getFileSystem();
>
>Sun did not go to all this trouble without expecting the actual
>separators to be normalized to whatever system a file is created on,
>so that no matter what your path happens to be in creating a File
>object, file.getName() should return the name without a file
>separator. Is this helpful?
>
>On 6/9/05, Mihael Knezevic <m....@porta.de> wrote:
>
>
>>this whole discussion is old. it can be found in the archives. the
>>implementation of the jvm on linux FROM SUN is faulty on this one. cause when
>>use use a filename like /tmp/mydir/myfile.txt and make a file object of it on
>>a windows system and get the name you would get the name myfile.txt though
>>the file separator on windows is a backslash, thats ok. but on linux you
>>won't get the name from a windows path. i send a bug report to sun. there was
>>some misunderstanding and then Dakota Jack <dakota.jack (at) gmail.com> send
>>also a bug report to sun. perhaps it is in the bug list by now.
>>
>>and yes the ie sends the full path. call it a bug or a feature.
>>
>>just replacing the backslash with a slash won't solve every case but most
>>cases.
>>
>>---------------------------------------------------------------------
>>To unsubscribe, e-mail: commons-user-unsubscribe@jakarta.apache.org
>>For additional commands, e-mail: commons-user-help@jakarta.apache.org
>>
>>
>>
>>
>
>
>
>
--
Kind Regards
Schalk Neethling
Web Developer.Designer.Programmer.President
Volume4.Business.Solution.Developers
emotionalize.conceptualize.visualize.realize
Landlines
Tel: +27125468436
Fax: +27125468436
Web
email:schalk@volume4.com
Global: www.volume4.com
Messenger
Yahoo!: v_olume4
AOL: v0lume4
MSN: volume4_@hotmail.com
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: commons-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: commons-user-help@jakarta.apache.org
Re: [fileUpload] Question about file name
Posted by Dakota Jack <da...@gmail.com>.
Yup:
Frank,
If the File class does not normalize the string used to create the
File, then there is a bug. There seems to be a bug in one version of
Linux and that has been reported to Sun. The constructor for File is
as follows:
public File(String pathname) {
if (pathname == null) {
throw new NullPointerException();
}
this.path = fs.normalize(pathname);
this.prefixLength = fs.prefixLength(this.path);
}
Notice that an object fs is called to normalize the pathname. The
object fs is created as a static field in all File classes as follows:
static private FileSystem fs = FileSystem.getFileSystem();
The FileSystem class is an abstract class that has to be implemented,
of course, for the os on which it exists. So, the basis for the class
is a JNI method:
public static native FileSystem getFileSystem();
Sun did not go to all this trouble without expecting the actual
separators to be normalized to whatever system a file is created on,
so that no matter what your path happens to be in creating a File
object, file.getName() should return the name without a file
separator. Is this helpful?
On 6/9/05, Mihael Knezevic <m....@porta.de> wrote:
> this whole discussion is old. it can be found in the archives. the
> implementation of the jvm on linux FROM SUN is faulty on this one. cause when
> use use a filename like /tmp/mydir/myfile.txt and make a file object of it on
> a windows system and get the name you would get the name myfile.txt though
> the file separator on windows is a backslash, thats ok. but on linux you
> won't get the name from a windows path. i send a bug report to sun. there was
> some misunderstanding and then Dakota Jack <dakota.jack (at) gmail.com> send
> also a bug report to sun. perhaps it is in the bug list by now.
>
> and yes the ie sends the full path. call it a bug or a feature.
>
> just replacing the backslash with a slash won't solve every case but most
> cases.
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: commons-user-unsubscribe@jakarta.apache.org
> For additional commands, e-mail: commons-user-help@jakarta.apache.org
>
>
--
"You can lead a horse to water but you cannot make it float on its back."
~Dakota Jack~
---------------------------------------------------------------------
To unsubscribe, e-mail: commons-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: commons-user-help@jakarta.apache.org
Re: [fileUpload] Question about file name
Posted by Mihael Knezevic <m....@porta.de>.
this whole discussion is old. it can be found in the archives. the
implementation of the jvm on linux FROM SUN is faulty on this one. cause when
use use a filename like /tmp/mydir/myfile.txt and make a file object of it on
a windows system and get the name you would get the name myfile.txt though
the file separator on windows is a backslash, thats ok. but on linux you
won't get the name from a windows path. i send a bug report to sun. there was
some misunderstanding and then Dakota Jack <dakota.jack (at) gmail.com> send
also a bug report to sun. perhaps it is in the bug list by now.
and yes the ie sends the full path. call it a bug or a feature.
just replacing the backslash with a slash won't solve every case but most
cases.
---------------------------------------------------------------------
To unsubscribe, e-mail: commons-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: commons-user-help@jakarta.apache.org
Re: [fileUpload] Question about file name
Posted by "Frank W. Zammetti" <fz...@omnytex.com>.
On Thu, June 9, 2005 4:35 pm, Martin Cooper said:
> 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.
Good point.
OK, so thinking simplistically..
final char PATH_SEP = File.pathSeparatorChar;
final char ANTI_PATH_SEP = File.pathSeparatorChar == '/' ? '\\' : '/';
String test = "/sub/dev/test.txt";
int lastSep;
lastSep = test.lastIndexOf(PATH_SEP);
if (lastSep == -1) {
lastSep = test.lastIndexOf(ANTI_PATH_SEP);
}
Should do the trick, no?
> Martin Cooper
--
Frank W. Zammetti
Founder and Chief Software Architect
Omnytex Technologies
http://www.omnytex.com
---------------------------------------------------------------------
To unsubscribe, e-mail: commons-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: commons-user-help@jakarta.apache.org
Re: [fileUpload] Question about file name
Posted by Schalk Neethling <sc...@volume4.com>.
Thanks Martin
Martin Cooper wrote:
>On 6/9/05, William Noto <wn...@openfinance.com> 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 wnoto@openfinance.com
>>
>>
>>-----Original Message-----
>>From: Schalk Neethling [mailto:schalk@volume4.com]
>>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 <sc...@volume4.com> 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:schalk@volume4.com
>>>>Global: www.volume4.com
>>>>Messenger
>>>>Yahoo!: v_olume4
>>>>AOL: v0lume4
>>>>MSN: volume4_@hotmail.com
>>>>
>>>>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: commons-user-unsubscribe@jakarta.apache.org
>>>>For additional commands, e-mail: commons-user-help@jakarta.apache.org
>>>>
>>>>
>>>>
>>>>
>>>>
>>>>
>>>
>>>
>>>
>>>
>>>
>>--
>>Kind Regards
>>Schalk Neethling
>>Web Developer.Designer.Programmer.President
>>Volume4.Business.Solution.Developers
>>emotionalize.conceptualize.visualize.realize
>>Landlines
>>Tel: +27125468436
>>Fax: +27125468436
>>Web
>>email:schalk@volume4.com
>>Global: www.volume4.com
>>Messenger
>>Yahoo!: v_olume4
>>AOL: v0lume4
>>MSN: volume4_@hotmail.com
>>
>>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: commons-user-unsubscribe@jakarta.apache.org
>>For additional commands, e-mail: commons-user-help@jakarta.apache.org
>>
>>
>>
>>
>>
>>
>
>
>
>
>
--
Kind Regards
Schalk Neethling
Web Developer.Designer.Programmer.President
Volume4.Business.Solution.Developers
emotionalize.conceptualize.visualize.realize
Landlines
Tel: +27125468436
Fax: +27125468436
Web
email:schalk@volume4.com
Global: www.volume4.com
Messenger
Yahoo!: v_olume4
AOL: v0lume4
MSN: volume4_@hotmail.com
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: commons-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: commons-user-help@jakarta.apache.org
Re: [fileUpload] Question about file name
Posted by Schalk Neethling <sc...@volume4.com>.
Thanks William. Small app this so I did not use struts but just the jar.
William Noto wrote:
>Oh right - duh.
>
>FWIW: I'm doing similar file uploading stuff on my project but I'm using
>org.apache.struts.upload.FormFile which has a getFileName() method that
>always gives me just the file's name without any of the path hoohah. I
>don't know if using this object requires using struts (or if that would be a
>problem for you) but I found it very easy to use.
>
>William B. Noto Open Finance 71 Gansevoort Street, Suite 2D, New York,
>NY 10014
>Tel + 1 646 230 8666 Fax + 1 646 230 8657 wnoto@openfinance.com
>
>
>-----Original Message-----
>From: Martin Cooper [mailto:mfncooper@gmail.com]
>Sent: Thursday, June 09, 2005 4:36 PM
>To: William Noto
>Cc: Jakarta Commons Users List; schalk@volume4.com
>Subject: Re: [fileUpload] Question about file name
>
>On 6/9/05, William Noto <wn...@openfinance.com> 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 wnoto@openfinance.com
>>
>>
>>-----Original Message-----
>>From: Schalk Neethling [mailto:schalk@volume4.com]
>>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 <sc...@volume4.com> 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:schalk@volume4.com
>>>>Global: www.volume4.com
>>>>Messenger
>>>>Yahoo!: v_olume4
>>>>AOL: v0lume4
>>>>MSN: volume4_@hotmail.com
>>>>
>>>>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: commons-user-unsubscribe@jakarta.apache.org
>>>>For additional commands, e-mail: commons-user-help@jakarta.apache.org
>>>>
>>>>
>>>>
>>>>
>>>>
>>>>
>>>
>>>
>>>
>>>
>>>
>>--
>>Kind Regards
>>Schalk Neethling
>>Web Developer.Designer.Programmer.President
>>Volume4.Business.Solution.Developers
>>emotionalize.conceptualize.visualize.realize
>>Landlines
>>Tel: +27125468436
>>Fax: +27125468436
>>Web
>>email:schalk@volume4.com
>>Global: www.volume4.com
>>Messenger
>>Yahoo!: v_olume4
>>AOL: v0lume4
>>MSN: volume4_@hotmail.com
>>
>>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: commons-user-unsubscribe@jakarta.apache.org
>>For additional commands, e-mail: commons-user-help@jakarta.apache.org
>>
>>
>>
>>
>>
>>
>
>---------------------------------------------------------------------
>To unsubscribe, e-mail: commons-user-unsubscribe@jakarta.apache.org
>For additional commands, e-mail: commons-user-help@jakarta.apache.org
>
>
>
>
>
>
>
--
Kind Regards
Schalk Neethling
Web Developer.Designer.Programmer.President
Volume4.Business.Solution.Developers
emotionalize.conceptualize.visualize.realize
Landlines
Tel: +27125468436
Fax: +27125468436
Web
email:schalk@volume4.com
Global: www.volume4.com
Messenger
Yahoo!: v_olume4
AOL: v0lume4
MSN: volume4_@hotmail.com
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: commons-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: commons-user-help@jakarta.apache.org
RE: [fileUpload] Question about file name
Posted by William Noto <wn...@openfinance.com>.
Oh right - duh.
FWIW: I'm doing similar file uploading stuff on my project but I'm using
org.apache.struts.upload.FormFile which has a getFileName() method that
always gives me just the file's name without any of the path hoohah. I
don't know if using this object requires using struts (or if that would be a
problem for you) but I found it very easy to use.
William B. Noto Open Finance 71 Gansevoort Street, Suite 2D, New York,
NY 10014
Tel + 1 646 230 8666 Fax + 1 646 230 8657 wnoto@openfinance.com
-----Original Message-----
From: Martin Cooper [mailto:mfncooper@gmail.com]
Sent: Thursday, June 09, 2005 4:36 PM
To: William Noto
Cc: Jakarta Commons Users List; schalk@volume4.com
Subject: Re: [fileUpload] Question about file name
On 6/9/05, William Noto <wn...@openfinance.com> 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 wnoto@openfinance.com
>
>
> -----Original Message-----
> From: Schalk Neethling [mailto:schalk@volume4.com]
> 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 <sc...@volume4.com> 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:schalk@volume4.com
> >>Global: www.volume4.com
> >>Messenger
> >>Yahoo!: v_olume4
> >>AOL: v0lume4
> >>MSN: volume4_@hotmail.com
> >>
> >>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: commons-user-unsubscribe@jakarta.apache.org
> >>For additional commands, e-mail: commons-user-help@jakarta.apache.org
> >>
> >>
> >>
> >>
> >
> >
> >
> >
> >
>
> --
> Kind Regards
> Schalk Neethling
> Web Developer.Designer.Programmer.President
> Volume4.Business.Solution.Developers
> emotionalize.conceptualize.visualize.realize
> Landlines
> Tel: +27125468436
> Fax: +27125468436
> Web
> email:schalk@volume4.com
> Global: www.volume4.com
> Messenger
> Yahoo!: v_olume4
> AOL: v0lume4
> MSN: volume4_@hotmail.com
>
> 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: commons-user-unsubscribe@jakarta.apache.org
> For additional commands, e-mail: commons-user-help@jakarta.apache.org
>
>
>
>
---------------------------------------------------------------------
To unsubscribe, e-mail: commons-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: commons-user-help@jakarta.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: commons-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: commons-user-help@jakarta.apache.org
Re: [fileUpload] Question about file name
Posted by Martin Cooper <mf...@gmail.com>.
On 6/9/05, William Noto <wn...@openfinance.com> 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 wnoto@openfinance.com
>
>
> -----Original Message-----
> From: Schalk Neethling [mailto:schalk@volume4.com]
> 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 <sc...@volume4.com> 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:schalk@volume4.com
> >>Global: www.volume4.com
> >>Messenger
> >>Yahoo!: v_olume4
> >>AOL: v0lume4
> >>MSN: volume4_@hotmail.com
> >>
> >>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: commons-user-unsubscribe@jakarta.apache.org
> >>For additional commands, e-mail: commons-user-help@jakarta.apache.org
> >>
> >>
> >>
> >>
> >
> >
> >
> >
> >
>
> --
> Kind Regards
> Schalk Neethling
> Web Developer.Designer.Programmer.President
> Volume4.Business.Solution.Developers
> emotionalize.conceptualize.visualize.realize
> Landlines
> Tel: +27125468436
> Fax: +27125468436
> Web
> email:schalk@volume4.com
> Global: www.volume4.com
> Messenger
> Yahoo!: v_olume4
> AOL: v0lume4
> MSN: volume4_@hotmail.com
>
> 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: commons-user-unsubscribe@jakarta.apache.org
> For additional commands, e-mail: commons-user-help@jakarta.apache.org
>
>
>
>
---------------------------------------------------------------------
To unsubscribe, e-mail: commons-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: commons-user-help@jakarta.apache.org
RE: [fileUpload] Question about file name
Posted by William Noto <wn...@openfinance.com>.
Won't you still have an OS dependency in there with that \\?
I think you can use File.pathSeperatorChar to handle that.
William B. Noto Open Finance 71 Gansevoort Street, Suite 2D, New York,
NY 10014
Tel + 1 646 230 8666 Fax + 1 646 230 8657 wnoto@openfinance.com
-----Original Message-----
From: Schalk Neethling [mailto:schalk@volume4.com]
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 <sc...@volume4.com> 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:schalk@volume4.com
>>Global: www.volume4.com
>>Messenger
>>Yahoo!: v_olume4
>>AOL: v0lume4
>>MSN: volume4_@hotmail.com
>>
>>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: commons-user-unsubscribe@jakarta.apache.org
>>For additional commands, e-mail: commons-user-help@jakarta.apache.org
>>
>>
>>
>>
>
>
>
>
>
--
Kind Regards
Schalk Neethling
Web Developer.Designer.Programmer.President
Volume4.Business.Solution.Developers
emotionalize.conceptualize.visualize.realize
Landlines
Tel: +27125468436
Fax: +27125468436
Web
email:schalk@volume4.com
Global: www.volume4.com
Messenger
Yahoo!: v_olume4
AOL: v0lume4
MSN: volume4_@hotmail.com
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: commons-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: commons-user-help@jakarta.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: commons-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: commons-user-help@jakarta.apache.org
Re: [fileUpload] Question about file name
Posted by Schalk Neethling <sc...@volume4.com>.
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 <sc...@volume4.com> 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:schalk@volume4.com
>>Global: www.volume4.com
>>Messenger
>>Yahoo!: v_olume4
>>AOL: v0lume4
>>MSN: volume4_@hotmail.com
>>
>>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: commons-user-unsubscribe@jakarta.apache.org
>>For additional commands, e-mail: commons-user-help@jakarta.apache.org
>>
>>
>>
>>
>
>
>
>
>
--
Kind Regards
Schalk Neethling
Web Developer.Designer.Programmer.President
Volume4.Business.Solution.Developers
emotionalize.conceptualize.visualize.realize
Landlines
Tel: +27125468436
Fax: +27125468436
Web
email:schalk@volume4.com
Global: www.volume4.com
Messenger
Yahoo!: v_olume4
AOL: v0lume4
MSN: volume4_@hotmail.com
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: commons-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: commons-user-help@jakarta.apache.org
Re: [fileUpload] Question about file name
Posted by Schalk Neethling <sc...@volume4.com>.
Thanks everyone, I will surely find a cross OS solution combining all of
these.
James Sangster wrote:
>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:schalk@volume4.com]
>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 <sc...@volume4.com> 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:schalk@volume4.com
>>>Global: www.volume4.com
>>>Messenger
>>>Yahoo!: v_olume4
>>>AOL: v0lume4
>>>MSN: volume4_@hotmail.com
>>>
>>>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: commons-user-unsubscribe@jakarta.apache.org
>>>For additional commands, e-mail: commons-user-help@jakarta.apache.org
>>>
>>>
>>>
>>>
>>>
>>>
>>---------------------------------------------------------------------
>>To unsubscribe, e-mail: commons-user-unsubscribe@jakarta.apache.org
>>For additional commands, e-mail: commons-user-help@jakarta.apache.org
>>
>>
>>
>>
>>
>>
>>
>>
>
>
>
--
Kind Regards
Schalk Neethling
Web Developer.Designer.Programmer.President
Volume4.Business.Solution.Developers
emotionalize.conceptualize.visualize.realize
Landlines
Tel: +27125468436
Fax: +27125468436
Web
email:schalk@volume4.com
Global: www.volume4.com
Messenger
Yahoo!: v_olume4
AOL: v0lume4
MSN: volume4_@hotmail.com
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: commons-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: commons-user-help@jakarta.apache.org
RE: [fileUpload] Question about file name
Posted by James Sangster <ja...@newswire.ca>.
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:schalk@volume4.com]
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 <sc...@volume4.com> 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:schalk@volume4.com
>>Global: www.volume4.com
>>Messenger
>>Yahoo!: v_olume4
>>AOL: v0lume4
>>MSN: volume4_@hotmail.com
>>
>>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: commons-user-unsubscribe@jakarta.apache.org
>>For additional commands, e-mail: commons-user-help@jakarta.apache.org
>>
>>
>>
>>
>
>---------------------------------------------------------------------
>To unsubscribe, e-mail: commons-user-unsubscribe@jakarta.apache.org
>For additional commands, e-mail: commons-user-help@jakarta.apache.org
>
>
>
>
>
>
--
Kind Regards
Schalk Neethling
Web Developer.Designer.Programmer.President
Volume4.Business.Solution.Developers
emotionalize.conceptualize.visualize.realize
Landlines
Tel: +27125468436
Fax: +27125468436
Web
email:schalk@volume4.com
Global: www.volume4.com
Messenger
Yahoo!: v_olume4
AOL: v0lume4
MSN: volume4_@hotmail.com
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: commons-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: commons-user-help@jakarta.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: commons-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: commons-user-help@jakarta.apache.org
Re: [fileUpload] Question about file name
Posted by Schalk Neethling <sc...@volume4.com>.
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 <sc...@volume4.com> 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:schalk@volume4.com
>>Global: www.volume4.com
>>Messenger
>>Yahoo!: v_olume4
>>AOL: v0lume4
>>MSN: volume4_@hotmail.com
>>
>>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: commons-user-unsubscribe@jakarta.apache.org
>>For additional commands, e-mail: commons-user-help@jakarta.apache.org
>>
>>
>>
>>
>
>---------------------------------------------------------------------
>To unsubscribe, e-mail: commons-user-unsubscribe@jakarta.apache.org
>For additional commands, e-mail: commons-user-help@jakarta.apache.org
>
>
>
>
>
>
--
Kind Regards
Schalk Neethling
Web Developer.Designer.Programmer.President
Volume4.Business.Solution.Developers
emotionalize.conceptualize.visualize.realize
Landlines
Tel: +27125468436
Fax: +27125468436
Web
email:schalk@volume4.com
Global: www.volume4.com
Messenger
Yahoo!: v_olume4
AOL: v0lume4
MSN: volume4_@hotmail.com
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: commons-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: commons-user-help@jakarta.apache.org
Re: [fileUpload] Question about file name
Posted by Martin Cooper <mf...@gmail.com>.
On 6/9/05, Schalk Neethling <sc...@volume4.com> 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:schalk@volume4.com
> Global: www.volume4.com
> Messenger
> Yahoo!: v_olume4
> AOL: v0lume4
> MSN: volume4_@hotmail.com
>
> 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: commons-user-unsubscribe@jakarta.apache.org
> For additional commands, e-mail: commons-user-help@jakarta.apache.org
>
>
---------------------------------------------------------------------
To unsubscribe, e-mail: commons-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: commons-user-help@jakarta.apache.org