I have a PHP app where I can upload files. When I upload most files and do a print_r($_FILES)
, I get something like this:
Array
(
[import] => Array
(
[name] => Array
(
[excel_file] => COD MKTG 2.csv
)
[type] => Array
(
[excel_file] => application/vnd.ms-excel
)
[tmp_name] => Array
(
[excel_file] => /tmp/phpy8mEKn
)
[error] => Array
(
[excel_file] => 0
)
[size] => Array
(
[excel_file] => 1584286
)
)
)
I have another CSV file that's more like 13 megabytes, and when I try to upload that, I get this:
Array
(
[import] => Array
(
[name] => Array
(
[excel_file] => COD MKTG.csv
)
[type] => Array
(
[excel_file] =>
)
[tmp_name] => Array
(
[excel_file] =>
)
[error] => Array
(
[excel_file] => 1
)
[size] => Array
(
[excel_file] => 0
)
)
)
I don't get any error saying the file's too big. I just get a malformed $_FILES
. I have post_max_size
in php.ini set to 100MB. Why is this happening?
As per the PHP docs, error code 1 is UPLOAD_ERR_INI_SIZE: "The uploaded file exceeds the upload_max_filesize directive in php.ini"
You need to make sure all the following variables are properly set:
upload_max_filesize - max size of any individual file in an upload
max_file_uploads - total number of files allowed to be uploaded
post_max_size - sum total of all data being POSTed (form data + files)
memory_limit - must be > post_max_size, to allow space for PHP + script overhead
And on top of that, there's the web server limits as well. Apache's got LimitRequestBody which would apply long before PHP ever enters the picture.
change the memory limit aswell memory_limit = 8M ;
to perhaps 20?
and perhaps execution time
max_execution_time
edit:
make sure its not execution time look it up...
if you got a really slow internet connection it could be
max_input_time
it has to be one of these or there's something wrong with your script or your not setting the settings correctly
memory_limit
max_execution_time
max_input_time
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With