note 91666 added to function.move-uploaded-file

From: Date: Mon, 22 Jun 2009 11:23:02 +0000
Subject: note 91666 added to function.move-uploaded-file
Groups: php.notes 
Request: Send a blank email to php-notes+get-157215@lists.php.net to get a copy of this message
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. ---- Server IP: 69.147.83.197 Probable Submitter: 89.241.154.58 ---- Manual Page -- http://www.php.net/manual/en/function.move-uploaded-file.php Edit -- https://master.php.net/note/edit/91666 Del: integrated -- https://master.php.net/note/delete/91666/integrated Del: useless -- https://master.php.net/note/delete/91666/useless Del: bad code -- https://master.php.net/note/delete/91666/bad+code Del: spam -- https://master.php.net/note/delete/91666/spam Del: non-english -- https://master.php.net/note/delete/91666/non-english Del: in docs -- https://master.php.net/note/delete/91666/in+docs Del: other reasons-- https://master.php.net/note/delete/91666 Reject -- https://master.php.net/note/reject/91666 Search -- https://master.php.net/manage/user-notes.php

« previous php.notes (#157215) next »