Max Frai
Max Frai

Reputation: 64286

html, file uploading trouble

I have a trouble with file-uploding. Here is my part of the form:

<input type="file" name="image_file" />
<input type="submit" name="add_new" value="Upload" />

And in script i have a code:

print_r($_FILES);

After image choosing and sending form, I have an empty array $_FILES. Why?

Upvotes: 0

Views: 112

Answers (2)

user175672
user175672

Reputation:

Have you set the form method to POST data to the PHP script and set the action to point to it? If so then you should be able to get something like $_FILES['image_file']['name']

Upvotes: 0

Vincent Ramdhanie
Vincent Ramdhanie

Reputation: 103135

The form must be set like this:

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

So that the browser knows to send the image along with the data.

Upvotes: 4

Related Questions