donglian1523 2018-10-03 11:40
浏览 44
已采纳

PHP - $ _FILES没有出现[重复]

This question already has an answer here:

I have a fairly simple form on my site. Just a text input and a file input.

<form action='myFile.php' method='POST'>
    <input type='text' id='image_description' name='image_description'>
    <input type='file' id='image' name='image'>
    <button onclick="this.form.submit();">Submit</button>
</form>

When I submit I have var_dump($_POST) and var_dump($_FILES).

I can see everything I entered in the text fields but the file does not seem to be coming through.

array(2) {
    ["image_description"]=> string(4) "test"
    ["image"]=> string(14) "Untitled-1.png"
}

array(0) {

}

This is happening both locally on WAMP and on my shared hosting domain.

Any ideas or possible reasons this could be happening or how to resolve it would be greatly appreciated.

</div>
  • 写回答

1条回答 默认 最新

  • dth20986 2018-10-03 11:43
    关注

    You should add in your Form

    enctype="multipart/form-data"

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论

报告相同问题?