I'm trying to upload an image to a php script. I have a, non-persistent, bug that results in some of the images uploaded has a file size of 0. I have tried to print the _FILES array to my log file, and it shows the error code being 0, which should be ok.
These lines:
foreach($_FILES['image_file'] as $key => $val){
error_log(date('j/n/o H:i:s')." ". $key ." => ".$val. "\n", 3,$log_path);
}
Give me these in the log file:
- 3/10/2012 12:12:54 name => 59175248636.jpg
- 3/10/2012 12:12:54 type => image/jpeg
- 3/10/2012 12:12:54 tmp_name => C:\WINDOWS\Temp\php411F.tmp
- 3/10/2012 12:12:54 error => 0
- 3/10/2012 12:12:54 size => 0
As can be read from the log file, this script runs on a Windows machine, of which I have limited knowledge. I have already changed the post_max_size to 10M, as well as upload_max_size to 10M in the php.ini.
I am flabbergasted about this issue. When I test from my own devices, it works fine, but for some reason, when my testers try it out, it fails.
EDIT - Try this:
I think you may need to change $_FILES['file'] to $_FILES['image_file'] to work with your setup. I have left it as below for ease of reading...
This doesn't solve the random filesize issue, but it will allow your code / process to continue. Treat it as a failed upload and tell the user to try again...
Used code from this stackoverflow post posted by Marc B