--- Marian Briones <[EMAIL PROTECTED]> wrote:
> I am working with a system that will have users uploading files,and I
> can't depend on them not using spaces and other things Unix doesnt'
> like in their file names (like ', ., etc).
Run the filename variable through some REGEX or str_replace before
sending it along. Strip out all funky characters and replace them with
either nothing or underscores (or dashes, whatever) to ensure their
unix-friendliness. I would also drop everything to lowercase.
str_replace is probably all you need -- regex can be a little
server-intensive.
$photo = "This is a photo of my dog, Skippy!.jpg";
$funkychars = array('\'', '.', ',', '$', '!', ' ');
$photo = str_replace($funkychars, '_', $photo);
$photo = strtolower($photo);
becomes
$photo = "this_is_a_photo_of_my_dog__skippy_.jpg";
You could even define it a little further and do something like:
$funkychars1 = array('\'', '.', ',', '$', '!');
$funkychars2 = ' ';
$photo = str_replace($funkychars1, '', $photo);
$photo = str_replace($funkychars2, '_', $photo);
$photo = strtolower($photo);
which would yield
$photo = "this_is_a_photo_of_my_dog_skippy.jpg";
HTH,
_Bob
____________________________________________________
Start your day with Yahoo! - make it your home page
http://www.yahoo.com/r/hs
Community email addresses:
Post message: [email protected]
Subscribe: [EMAIL PROTECTED]
Unsubscribe: [EMAIL PROTECTED]
List owner: [EMAIL PROTECTED]
Shortcut URL to this page:
http://groups.yahoo.com/group/php-list
Yahoo! Groups Links
<*> To visit your group on the web, go to:
http://groups.yahoo.com/group/php-list/
<*> To unsubscribe from this group, send an email to:
[EMAIL PROTECTED]
<*> Your use of Yahoo! Groups is subject to:
http://docs.yahoo.com/info/terms/