Both the form and the data processer are on the same page. Configure the upload path and the max file size as per your requirements.
Source Code
// basic php file upload example
// http://php.snippetdb.com
if ($_POST['upload']){ //process uploaded file
$uploadDir = '/path/to/upload/directory/'; //file upload path
$uploadFile = $uploadDir . $_FILES['uploadfile']['name'];
echo ""
;
if (move_uploaded_file($_FILES['uploadfile']['tmp_name'], $uploadFile) )
{
echo "File is valid, and was successfully uploaded. ";
echo "Here's some more debugging info:";
}
else
{
echo "ERROR! Here's some debugging info:";
echo "remember to check valid path, max filesize";
}
var_dump($_FILES);
echo "";
} else { //display upload form
?>
}
?>