SEE ALSO PHP PAGE ON FILE UPLOADS: https://skanky.dev/cloud/php/forms/post-file-uploads
Including 1 or more files to be uploadedĀ in a form
The data encoding type enctype MUST be specified as “multipart/form-data”:
<form enctype="multipart/form-data" action="__URL__" method="POST">
You can include one or more files like this:
<input type="hidden" name="MAX_FILE_SIZE" value="30000" /> MAX_FILE_SIZE must precede the file input field
<label>Send this file</label>
<input name="file_uploaded1" type="file" />
Handling in PHP
//----- HANDLE THE FILE UPLOADS -----
//Delete any existing files
unlink("/var/www/html/files/ca.pem");
//Move the uploaded file from the temporary directory it was uploaded to
echo '<pre>';
if (move_uploaded_file($_FILES['file_uploaded1']['tmp_name'], "/var/www/html/files/ca.pem"))
{
echo "File is valid, and was successfully uploaded.\n";
}
else
{
echo "Possible file upload attack!\n";
}
echo 'Here is some more debugging info:';
print_r($_FILES);
print "</pre>";
Feel free to comment if you can add help to this page or point out issues and solutions you have found. I do not provide support on this site, if you need help with a problem head over to stack overflow.