>So with this users can name the files any way they want, and the name will be
>changed upon upload?
Yes.
>Where do you put this?
Well, I don´t know how exactly you handle uploads, but usually you fill have a form, something like this
<FORM ACTION="$PHP_SELF" METHOD=POST ENCTYPE="multipart/form-data">
<INPUT TYPE=FILE NAME="userfile"><BR>
<INPUT TYPE=HIDDEN NAME="action" VALUE="post">
So after the file is uploaded, the file is under the php variable $userfile .
To tidy its name, I do the following:
//tidy up user's filename
$userfile_name = str_replace(" ", "_", $userfile_name);
$userfile_name = preg_replace('([^_a-zA-Z0-9\-\.])', '', $userfile_name);
$userfile_name = str_replace(".jpeg", ".jpg", $userfile_name);
$userfile_name = str_replace(".JPG", ".jpg", $userfile_name);
$userfile_name = str_replace(".GIF", ".gif", $userfile_name);
$userfile_name = str_replace(".PNG", ".png", $userfile_name);
Read
http://at2.php.net/features.file-upload Here is a tutorial on file upload.
http://www.zend.com/zend/spotlight/uploading.php also here:
http://forums.devshed.com/archive/5/2001/3/3/12353