note 41190 deleted from features.file-upload by aidan
| From: | aidan@php.net | Date: | Thu, 05 Aug 2004 07:45:12 +0000 |
| Subject: | note 41190 deleted from features.file-upload by aidan | ||
| References: | 1 | Groups: | php.notes |
| Request: | Send a blank email to php-notes+get-73976@lists.php.net to get a copy of this message | ||
Note Submitter: php@hsmx.com
----
When uploading files, it's good to check that a file does not exist on your server with the
same name, or it will be overwritten.
Here's my solution:
$fileonserver = $pathonserver.$file_name;
while (file_exists($fileonserver))
{
$rand = rand(0, 9);
$file_name = $rand.$file_name;
$fileonserver = $pathonserver.$file_name;
}