Posted under » PHP on 25 October 2009
This script will allow you to upload files from your browser to your hosting, using PHP. The first thing we need to do is create an HTML form that allows people to choose the file they want to upload. Note the enctype part.
The upload.php script file itself is very small. You should chmod the $target to 777.
<¿php // make sure its writable $target = "/unux/domains/public_html/docs/"; $target = $target . basename( $_FILES['uploaded']['name']) ; $ok=1; //This is our size condition if ($uploaded_size > 350000) { $kontent .= "Your file is too large.<br>"; $ok=0; } //This is our limit file type condition if ($uploaded_type =="text/php") { $kontent .= "No PHP files<br>"; $ok=0; } //Here we check that $ok was not set to 0 by an error if ($ok==0) { $kontent .= "Sorry your file was not uploaded"; } //If everything is ok we try to upload it else { if(move_uploaded_file($_FILES['uploaded']['tmp_name'], $target)) { $kontent .= "The file ". basename( $_FILES['uploadedfile']['name']). " has been uploaded"; } else { $kontent .= "Sorry, there was a problem uploading your file."; } } ?>
2016. Please note that $_FILES['uploaded']['type'] or $uploaded_type is not reliable.
There are limits to how much you can upload. You can adjust or restrict them by tweaking the php.ini.
post_max_size = 8M upload_max_filesize = 2M
Anything above 200mb should not be attempted over SSL or HTPPS sites as the encryption can kill the web server.
For update read here