note 91666 deleted from function.move-uploaded-file by danbrown
| From: | danbrown@php.net | Date: | Mon, 22 Jun 2009 12:42:21 +0000 |
| Subject: | note 91666 deleted from function.move-uploaded-file by danbrown | ||
| References: | 1 | Groups: | php.notes |
| Request: | Send a blank email to php-notes+get-157220@lists.php.net to get a copy of this message | ||
Note Submitter: ahydra
----
sedativchunk's code is a little poor in places. The most glaring error was using 25600 for
"200KB" when it should be 204800.
Also using a random number to distinguish between a new file and an already existing file
doesn't guarantee the old file will not be overwritten (the same number can appear twice). It
would be better to use a loop that checks "0000filename", "0001filename" etc
until it finds one that doesn't exist.
Johan already pointed out the problem with >3 character extensions.
Finally, why not declare the filename array in one line
$files = array('jpeg', 'jpg', 'gif', 'png');
(though using the MIME type may be better to weed out silly things like a TXT file uploaded with a
.gif extension)
There are a few other places where the code could be simplified also. It's a pity this code is
poorly written, as it provides a nice copy/paste for anyone wanting to debug file uploads.