PHP Undefined index error $_FILES?

后端 未结 4 573
暗喜
暗喜 2020-11-30 14:36

I am new to PHP and am following a tutorial on YouTube. I have everything working in this file, except for the file uploading, any help would be appreciated. Here is the e

4条回答
  •  没有蜡笔的小新
    2020-11-30 15:01

    first: try to strict programming

    error_reporting(E_ALL | E_STRICT);
    

    also you must use isset for check is index for array available or not

    if (isset($_POST['submitbtn']) && isset($_FILES['avatar'])) {
         // ...
    }
    

    also check php configuraion

    file_uploads    "1"
    upload_max_filesize     "2M"
    post_max_size   "8M"
    max_file_uploads    20
    

    post max size must be larger than upload max file size.

    also as guys said check form enctype

提交回复
热议问题