1

I am using the script posted here by w3school for uploading files to a webserver. I am using Google chrome going to an Apache server with php7.

When I upload a file from my windows desktop the script works as advertised and the file is uploaded. However when I attempt to upload a file from any other folder the $_FILES variable is either not there or it's values are empty (It actually appears to be a size issue, see edit below). I'm not sure how to troubleshoot this as the devtools on chrome don't seem to give me any information about what it is sending in this POST message.

I am assuming the problem is on the client side as it appears the server is getting no information from the client.

EDIT

I am aware of how to look at the headers for requests and nothing about the file except for its content length are included in the header. There is no difference between the headers that work and those that don't except the content boundary, which appears to be random, and the content-length header, which obviously changes with the size of the file.

I had a thought that this was related to the size of the file, and it is. I have a folder of different size photos and I sorted and uploaded increasingly larger files until it failed. It worked fine until around 8M files, and fails when they are larger than 8,200KB.

I checked the php.ini and I have it set to a max upload size of 150M, so it's not the ini file. I also check all the logs and nothing other than the post request shows up when I try to upload the file.

jeffpkamp
  • 2,732
  • 2
  • 27
  • 51
  • In dev tools select network, select the POST, choose the "headers" tab and then at the bottom you can see the form input. – doublesharp Jun 21 '19 at 22:00
  • @doublesharp The headers between a successful upload and an upload with no data transferred looks identical as I note in my edit above. – jeffpkamp Jun 22 '19 at 15:44

1 Answers1

1

I was able to find the answer here: why would $_FILES be empty when uploading files to PHP.

I did not know there was a post_max_size option in the php.ini file, which was set to 8M. Now that this is set to 100M. If you go over this size of a POST request php does not parse the POST information, thus giving you a blank $_FILES variable.

jeffpkamp
  • 2,732
  • 2
  • 27
  • 51
  • 1
    Also check out the `upload_max_filesize` php setting, and you might need to adjust the webserver settings too (if you are using nginx for example). – doublesharp Jun 22 '19 at 16:17