note 8512 added to Handling file uploads

From: Date: Thu, 14 Sep 2000 15:08:54 +0000
Subject: note 8512 added to Handling file uploads
Groups: php.notes 
Request: Send a blank email to php-notes+get-5003@lists.php.net to get a copy of this message
Running RedHat 6.2 with PHP3 I ran into a little trouble with making this work. I used the fragments in the chapter above and the windows post above but the final AH-HA came when I realized that I needed to add 2 things to make it all work: if (! $userfile) { $error_msg = "No file specified or file outside guidelines.\n"; return; } This allowed me to catch files that were out of spec according to the HTML that actually sent the file with TYPE=FILE. The kind of spec like INPUT TYPE="hidden" name="MAX_FILE_SIZE" value="500000" and so on. Also, I has to set permissions to the directory I was executing from and copying the temporary file to with the command: chmod o=rwx directoryname I am sure there are better ways, but this worked great! http://www.php.net/manual/features.file-upload.php

« previous php.notes (#5003) next »