Php download file gives error code 4. Why?

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 running print_r($_FILES)in formhandler.php after selecting the file and clicking submit:

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

And error code 4, according to the manual, means "UPLOAD_ERR_NO_FILE - the file was not loaded", but I can not understand why it was not downloaded.

+4
source share
1 answer

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

+7
source

Source: https://habr.com/ru/post/1526317/


All Articles