Rocket Rocket - 5 months ago 24
HTML Question

HTML File Upload issue

possibly a stupid question but how do I upload files to a server using the browser ?

I'm sure I've used this before ! But when I run it nothing appears to happen.

No errors are shown and nothing is logged in the error_log

echo $_FILES['uploadFile']['tmp_name'];


<title>File Upload Form</title>

This form allows you to upload a file to the server.<br>
<form action="test.php" method="post"><br>

Type (or select) Filename: <input type="file" name="uploadFile">
<input type="submit" value="Upload File">


What am I doing wrong ?


When you submit a form, the data you are sending to be encoded somehow to be put in the HTTP request.

By default, this uses the application/x-www-form-urlencoded algorithm which does not support file uploads. You need to use multipart/form-data instead.

<form action="test.php" method="post" enctype="multipart/form-data">