Forum Moderators: coopster

Message Too Old, No Replies

PHP file upload

         

lajkonik86

7:22 pm on Feb 1, 2005 (gmt 0)

10+ Year Member



Heey

I'm trying to upload a file trough an input box.
You know something like this:

<tr><td>Select the screenie.</td><td><input type=\"hidden\" name=\"MAX_FILE_SIZE\" value=\"1200000\" />
<input type=\"file\" name=\"bestand\"></td></tr>
<tr><td>&nbsp;</td><td><input type=\"submit\" name=\"submit\" value=\"" . $text . "\"></td></tr>
</table>

Don't know for certain what tha max_file_size does i'm sort of new to this. Well anyhow i got the thing to upload images and process them.
But when my jpg's get above 500kb i get an error from my move uploaded file script:

// VERPLAATSEN BESTAND
if(!copy($_FILES['bestand']['tmp_name'], $HTTP_SERVER_VARS['DOCUMENT_ROOT']. "/usermade/" .$gamedir . "/images/".$bestandsnaam)) {
echo "Uploading failed. Please click the back button in the browser and try again. This error could be triggered by trying to upload a file bigger then 1 mb.";
exit();
}

Any ideas to what might be causing this?

coopster

12:23 pm on Feb 2, 2005 (gmt 0)

WebmasterWorld Administrator 10+ Year Member



The best advice I could offer here would be to first review the PHP manual pages on Handling file uploads [php.net]. It explains the MAX_FILE_SIZE and also shows how to monitor for errors [php.net]. Lastly, don't forget to keep an eye not only on your
php.ini
configuration settings, but your Apache directives as well (LimitRequestBody [httpd.apache.org], etc.)

File uploads can be a bit difficult at first but taking the time to really understand how PHP does things behind the scenes will be a very worthwhile investment of your time.