Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Php upload file yields error code 4. Why?

The HTML:

<form action="formhandler.php" method="post" enctype="multipart/form-data">
    <input type="file" name="file" />
    <input type="submit" name="submit" value="Submit" />
</form>

and doing a print_r($_FILES) in formhandler.php after choosing a file and clicking submit yields:

[file] => Array
    (
        [name] => 
        [type] => 
        [tmp_name] => 
        [error] => 4
        [size] => 0
    )

And error code 4, according to the manual stands for "UPLOAD_ERR_NO_FILE - No file was uploaded" but I can't figure out why it wasn't uploaded.

like image 512
Weblurk Avatar asked Feb 11 '14 09:02

Weblurk


1 Answers

In this case, the problem was: I had multiple input elements with the attribute name="image". When I changed to individual names the error disappeared.

like image 174
Weblurk Avatar answered Sep 19 '22 06:09

Weblurk