I got the problem with my web server. I configured PHP to have max upload size 300MB. I changed 2 options in php.ini php_value upload_max_filesize 300MB php_value post_max_size 300MB
This works fine. But recently i noticed very big file in /tmp folder (this is temp folder for PHP). There were 3 files of a size 1.5GB and continue growing . file names were like temp php files /tmp/php** (** some random code).
And i checked that process writing to these files were my PHP script i created for uploading.
So my question is why PHP upload and post limit didn't affect on these files? What can be the reason? Maybe PHP saves all uploaded data to temp dir first and only after this calculates a size and check if it is good or not?
I appreciate any comments.
UPDATE. Can this be something like - http client sends a request without content-length heder so php can not use post_max_size to limit affect. And PHP writes everything to the disk because doesn't know what is the site of POST request and file in it?
You need to set the value of upload_max_filesize and post_max_size in your php.ini :
; Maximum allowed size for uploaded files.
upload_max_filesize = 300M
; Must be greater than or equal to upload_max_filesize
post_max_size = 300M
or in .htaccess
php_value upload_max_filesize 300M
php_value post_max_size 300M
Try to set a new tmp
directory with larger space and no limit rather than the system default (/tmp
). You can do so either by changing the default directory in the php.ini
file:
upload_tmp_dir = /scratch/custom_temp
or overwrite inside the php script:
<?php
ini_set('upload_tmp_dir', '/scratch/custom_temp');
?>