VPS Free Server File Size Limit
I am using a free server VPS. (2GB, 1CPU, 50GB)
I cannot upload files larger than 500kb. The php.ini file (/etc/php/7.2/apache2/php.ini) has the following values:
file_uploads = On
upload_max_filesize = 20M
post_max_size = 20M
max_execution_time = 300
max_input_time = 60
memory_limit = 128M ( I've also used -1)
The php script does not limit the size nor the file format.
No error is displayed in the file error.log.
10 Replies
You may be looking at the wrong php.ini for your purposes (that 'cli' in the path suggests that may be used for command line php).
You'll want to look at the output of phpinfo from the place you are trying to do the upload.
Create an info.php file in the directory with your uploading page:
<?php echo phpinfo();?>
Then hit that /info.php page with a web browser.
It should give you lots of information like the location of the php.ini(s) that it is using along with the settings for things like the post_max_size, upload_max_filesize, and memory_limit.
Millisa.
I already did all that. When I run the info.php file it shows those values.
I edit the php.ini file that is in the path /etc/php/7.2/apache2/php.ini
What happens when an upload fails? You mentioned there is nothing in error.log, but is there any info provided when you try to upload a >500KB file?
If php.ini isn't the issue, then the next likely candidate is your Apache .htaccess file.
I found this article that details what to look for in .htaccess, and it also provides a method for defining the limits within your individual php application itself.
_Brian.
This is what the error.log file reports:
PHP Notice: Unknown: file created in the system's temporary directory in Unknown on line 0
I already tried using a file .htaccess and it doesn't work either.
Could Linode be restricting the upload limit?
Linode is certainly not restricting the upload limit.
Based on the notice message you posted above, it looks like the permissions of the upload directory are wrong. You might consider setting the web server system user (usually it's www-data
but could be some other) as the owner of the upload directory with the chown
command.
Also, you can ensure PHP is using your system's tmp directory but commenting out the upload_tmp_dir
value in your php.ini
file.
You write:
Could Linode be restricting the upload limit?
More likely, some piece of your web server (e.g., SSL) has an upper limit on the size of POST requests. Look at your apache configuration:
https://stackoverflow.com/questions/8896644/request-entity-too-large/19447688#19447688
-- sw
ppetrovic
I can upload files smaller than 500KB.
I changed the owner to www-data, root and my user and the problem continues.
The upload_tmp_dir is committed in the php.ini file and using the system folder.
I tried adding LimitRequesBody = 25700000 to the apache2.conf file and it still doesn't work.
I'm sorry.
Errors were in the php code.
I changed the code and now everything is fine.
I still don't know which part of the code was wrong, I didn't program them.
Thanks to everyone