Why would $_FILES be empty when uploading files to PHP?

前端 未结 21 2710
一向
一向 2020-11-21 22:37

I have WampServer 2 installed on my Windows 7 computer. I\'m using Apache 2.2.11 and PHP 5.2.11. When I attempt to upload any file from a form, it seems to upload, but in PH

相关标签:
21条回答
  • 2020-11-21 23:12

    Here another cause I found: When using JQuery Mobile and the form attribute data-ajax is set to true, the FILES array will be empty. So set data-ajax to false.

    0 讨论(0)
  • 2020-11-21 23:12

    If you are trying to upload an array of files then you may need to increase max_file_uploads in php.ini which is by default set to 20

    Note: max_file_uploads can NOT be changed outside php.ini. See PHP "Bug" #50684

    0 讨论(0)
  • 2020-11-21 23:13

    As far as the HTML you appear to have set that part up correctly. You already have the enctype="multipart/form-data" which is very important to have on the form.

    As far as your php.ini setup, sometimes on systems multiple php.ini files exist. Be sure you are editing the correct one. I know you said you have configured your php.ini file to have file uploads, but did you also set your upload_max_filesize and post_max_size to be larger than the file you are trying to upload? So you should have:

    file_uploads = On; sounds like you already did this
    post_max_size = 8M; change this higher if needed
    upload_max_filesize = 8M; change this higher if needed
    

    Does your directory: "c:\wamp\tmp" have both read and write permissions? Did you remember to restart Apache after you made the php.ini changes?


    0 讨论(0)
  • 2020-11-21 23:14

    I too had problems with $_FILES empty. The above check-list do not mention MultiViews in .htaccess, httpd.conf or httpd-vhost.conf.

    If you have MultiViews set in the options directive for your directory containing the web site, $_FILES will be empty, even though Content-Length header if showing that the file i uploaded.

    0 讨论(0)
  • 2020-11-21 23:18

    If your main script is http://Some_long_URL/index.php be carefull to specify the full URL (with explicit index.php and not only http://Some_long_URL) in the action field. Surprisingly, if not, the right script is executed, but with en empty $_FILES !

    0 讨论(0)
  • 2020-11-21 23:21

    Make sure your input element has a 'name' attribute. <input type="file" name="uploadedfile" />

    If this is missing the $_FILES will be empty.

    0 讨论(0)
提交回复
热议问题