RE: [PHP] ie problem with file upload
| From: | Christensen, BruceX R | Date: | Tue, 08 Aug 2000 21:15:32 +0000 |
| Subject: | RE: [PHP] ie problem with file upload | ||
| Groups: | php.general | ||
| Request: | Send a blank email to php-general+get-10792@lists.php.net to get a copy of this message | ||
Here's what I do to get a nice filename from an uploaded file:
///////////////////////////////////////////////////////////
// clean_path: strip path information and illegal /////////
// characters from a filename /////////////////////////////
///////////////////////////////////////////////////////////
/*
Returns a legal filename w/o path info.
*/
function clean_path ($path) {
return ereg_replace("[:*?\"<>|]", "",
basename(str_replace('\\',
'/', $path)));
}
Note that this will only give you dogfood.txt, not blabla\woogy\dogfood.txt
or something similar. Because it only gives you the filename, you can put
it in whatever directory you want, without having to worry about creating
the extra directories specified (which you usually don't want, anyway).
(It's probably better to use an ereg() to match valid characters instead of
the ereg_replace() that I used to get rid of illegal characters, but this is
an intranet environment, where the name of the game is flexibility and
development time, not security.)
--Bruce
Bruce Christensen
Intel Corporation
brucex.r.christensen@intel.com
-----Original Message-----
From: Kevin Beckford [mailto:kbeckford@bigorbit.com]
Sent: Tuesday, August 08, 2000 2:07 PM
To: GPHP
Subject: [PHP] ie problem with file upload
When I upload a file with netscape - everything is fine and dandy, When I do
the same with IE, I get a filename in the form
C:\\blabla\\woogy\\dogfood.txt
What causes this, and what is the solution?
______________________________________
Kevin Beckford
Programmer
Big Orbit - Specializing in new media for youth
www: http://www.bigorbit.com
email: kbeckford@bigorbit.com
[t] 416.516.0705
[f] 416.516.9256
"Intelligence is a tool used achieve goals, however goals are not always
chosen
wisely..."
--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, e-mail: php-general-unsubscribe@lists.php.net
For additional commands, e-mail: php-general-help@lists.php.net
To contact the list administrators, e-mail: php-list-admin@lists.php.net