Re: WOFileUpload: checking against Windows filepath
Re: WOFileUpload: checking against Windows filepath
- Subject: Re: WOFileUpload: checking against Windows filepath
- From: David Holt <email@hidden>
- Date: Thu, 8 Dec 2005 15:07:06 -0800
Xavier,
Please don't cross post to both lists. See below for a solution that I found and posted last year.
David
Begin forwarded message:
From: David Holt <email@hidden>
Date: 15 December 2004 3:26:01 PM GMT-08:00
To: Chuck Hill <email@hidden>
Cc: WebObjectsDev <email@hidden>
Subject: Re: WOFileUpload bindings [SOLVED]
I tried using NSPathUtilities to get the last component, but it was still returning the absolute path on the Window's user's file system. In the end I went with a solution that had been posted back in May 2003. Instead of binding the filepath directly to the EO filename attribute, I now pass it to a temporary variable that is manipulated in java before being passed to the database. Here is the code I am using. Thanks Chuck, your suggestion eventually led me to this solution in a previous thread:
// When the WOFileUpload filepath key is bound to a value from WindowsIE it brings the complete
// absolute filepath to the user's file. This is not useful when it comes to storing
// the filename in the database or for downloading the file later. This code parses out the filename
// from a Windows IE generated filepath.
// the aFileName variable is bound to the filePath variable on the WOFileUpload component
// tempFileName is the parsed filename which is then passed to the EO as the real FileName
// before the changes to the Editing Context are committed to the database.
if ( (aFileName != null) && (aFileName.length() > 0) ) {
int length1 = aFileName.length();
String tempFileName = "";
int i=0; i< length1; i++) {
if(aFileName.substring(i, i"\\")) {
tempFileName="";
} else {
tempFileName = tempFileName + aFileName.substring(i,i+1);
}
}
anUpload.setFileName(tempFileName);
NSLog.out.appendln( "FileName: "+tempFileName );
} else {
NSLog.out.appendln( "No File Uploaded" );
}
--
--
True universality does not consist in knowing much, but in loving much.
<x-tad-smaller>
-Jakob Burckhardt
from Sunbeams: http://www.thesunmagazine.org</x-tad-smaller>
On 8 Dec 2005, at 2:56 PM, Dev WO wrote:
Hi all,
searching for solving an issue (I thought weren't be there) I found this thread...
I'm using NSPathUtilities.lastPathComponent, but it appears I still get the entire path!! like in the post below.
I'll ask my client tomorrow to check which version of IE was used.
But does anyone knows the fix?
Thanks
Xavier
on 7/23/04 11:47 PM, Hsu at email@hidden wrote:
NSPathUtilities is intended to work on both Mac(Unix) and Windows
paths... if it doesn't, it's a bug.
What's the specific path in question?
// theFileName is the filePath property of the WOUpload component
String fileName = NSPathUtilities.lastPathComponent(theFileName);
NSLog.out.appendln( "theFileName = " + theFileName );
NSLog.out.appendln( "fileName = " + fileName );
Here's the debug output:
theFileName = E:\tmp\shmeckle.zip
fileName = E:\tmp\shmeckle.zip
Karl
On Jul 23, 2004, at 6:24 PM, Randall Perry wrote:
On testing my file upload app on a Win2k machine I discovered that IE
in
Windows inserts the full path to the file in the browse field, whereas
on
the Mac only the filename appears.
My code checks the filename to see if it begins with a customer code.
I use
NSPathUtilities.lastPathComponent(), but apparently it doesn't work on
PC
paths.
Is there a method that does?
_______________________________________________
Do not post admin requests to the list. They will be ignored.
Webobjects-dev mailing list (email@hidden)
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden