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

//Delete any existing files
//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";
    echo "Possible file upload attack!\n";
echo 'Here is some more debugging info:';
print "</pre>";


We benefit hugely from resources on the web so we decided we should try and give back some of our knowledge and resources to the community by opening up many of our company’s internal notes and libraries through mini sites like this. We hope you find the site helpful.
Please feel free to comment if you can add help to this page or point out issues and solutions you have found, but please note that we do not provide support on this site. If you need help with a problem please use one of the many online forums.


Your email address will not be published.