Increase max file upload size for SilverStripe site - php

I am working on increasing the max upload file size for a SilverStripe site as I want the new limit to be 20 MB instead of 2 MB. I have placed this line of code in the root .htaccess file for the project:
php_value upload_max_filesize 20M
This works to some extent. It has increased the upload size limit, but only to 8 MB. I removed this line of code and tried uploading a large file again and the "file size exceeds 2 MB" error returned. So, what I have in place does work but only increases the file size limit to 8 MB.
I have been reading that there can be a php.ini file included in the project to increase the file size limit as well, but I am wondering if there is a way to do it through just the .htaccess file?

The reason for this problem is because you've not set your post_max_size. The post_max_size defaults to 8mb. So you need to do the following:
php_value upload_max_filesize 20M
php_value post_max_size 50M
You can obviously edit the post_max_size to something more suitable to what you need.

This 100% work in v4
Your problem is indeed related to php.ini.
In php.ini there is a section related to file uploads that will have the following line in it;
; Maximum allowed size for uploaded files.
upload_max_filesize = 2M
Change the 2M to be something more in line with what you need, then restart apache and you should be good to go.
It is also possible (though i have not tried this yet) to put the following line in to the .htaccess.
php_value upload_max_filesize 20M
Hope that helps.

Related

How to increase max_upload_size on apache server

In my application, I want to upload a file more than 500 MB, but it's giving me an error as the file is too big to upload.
I tried different ways to increase max_upload_size in php.ini and through .htacccess
but its increased till 128MB not more than that.
is there any way to increase it more than 500MB
Thanks in advance
To upload large files, post_max_size value must be larger than upload_max_filesize.
memory_limit should be larger than post_max_size
memory_limit > post_max_size > upload_max_filesize
PHP Default: 128M > 8M > 2M
So you can try to increase memory_limit as well if you've increased post_max_size and upload_max_filesize
I had the same issue before
I tried this plugin to increase it
https://wordpress.org/plugins/upload-max-file-size/
and
if it's not working you can edit in the htaccess file in WordPress directory and edit the file replacing xx with your preferred value
php_value upload_max_filesize xxM

The uploaded file exceeds the upload_max_filesize directive in php.ini but the file is smaller than limit

i have simple script for upload files, if i upload file <500Kb everything is working fine, but when i upload bigger file $_FILES['upload']['error'] return me 1.
I know that mean file exceeds the upload_max_filesize, but i set in .htacces php_value post_max_size 999999M and check ini_get('post_max_size') return me 999999M.
But script still don't work with file ~4MB let alone bigger file.
At the end, sorry for my eng (is not main basic lang)
By default, the maximum upload file size for PHP scripts is set to 128 megabytes. However, you may want to change these limits. You can set a limit by changing the upload_max_filesize and post_max_size directives in your php.ini file.
To ensure that file uploads work correctly, the post_max_size directive should be a little larger than the upload_max_filesize. For example, the following settings demonstrate how to set a file upload limit to 20 megabytes:
upload_max_filesize = 20M
post_max_size = 21M

How to change max upload size for files in Wordpress 4.4 at xampp

I wanted to upload a template to wordpress 4.4 which is running on xampp but it says that I only can upload 2MB. I've googled the problem and found an information that i need to change the parameter upload_max_filesize=32M in the file php.ini. I doesn't found the file in the Wordpress folder but in the xampp folder I found a file called php.ini with the parameter in it and I changed the parameter but nothing happened.
What can I do to increase the max template upload space?
Have you tried this already? http://www.wpbeginner.com/wp-tutorials/how-to-increase-the-maximum-file-upload-size-in-wordpress/ It contains plenty of ways to increase the max upload size.
Make sure you increase post_max_size and upload_max_filesize, both limits.
So for example in PHP.ini:
upload_max_filesize = 64M
post_max_size = 64M
max_execution_time = 300
Cause it may take longer to upload those files, you might want to increase max_execution_time as well.
post_max_size is the maximum size for all POST body data. upload_max_filesize is a maximum size only for files that are POSTed. Other types of POST body data are not subject to this limit. See Brad's answer over here: PHP post_max_size vs upload_max_filesize, what is the difference?

PHP upload limit does not affect. Big files are in /tmp folder

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');
?>

cannot change php upload size limit

I used uplaodify plugin to upload music files. Everyting is okay in my local
uploadify.php file is in public_html/uploadify directory
i want to increment my upload file size limit to 10 MB
i tried to put
php.ini file in public_html
post_max_size = 500M
upload_max_filesize = 500M
max_execution_time = 900;
max_input_time 900
and I am looking my phpinfo() thats good
but ı cannot upload bigger than 2MB
And i tried to put same php.ini in public_html/uploadify
Now I can upload file which size 2.5 MB , but no upper;
And
ini_set('upload_max_size','10M');
ini_set('post_max_size','10M');
ini_set('max_execution_time','900');
lines is in the my index.php and uploadify.php
What should I do increment my file upload size limit
EDIT
I look $_FILES[..]['error'], and its 7
UPLOAD_ERR_CANT_WRITE
Value: 7; Failed to write file to disk. Introduced in PHP 5.1.0.
But I can upload file which smaller than 2.5 MB
Edit the .htaccess file in the root folder and add these values:
RewriteEngine On
php_value post_max_size 1000M
php_value upload_max_filesize 1000M
php_value max_execution_time 6000000
You can edit it to suit your needs. 1000M = 1GB, so edit accordingly. Do note that your host will need to allow PHP edits.
You cannot override upload limits from within a script using ini_set - the upload will have completed (or been aborted) using the original settings long before PHP fires up and processes the ini_sets.
You can't just litter php.ini files around your system either - php doesn't load random .ini files it finds lying around. It only loads them from specific locations. If PHP hasn't been told to load one from the uploadify directory, you'll have to use a .htaccess and php_value directives.
Hello I had the similar issue while uploading a theme on wordpress on localhost. After hours of research I was able to put following 3 lines in my php.ini and restarted the apache and it worked. I thought this will help others.
This will go in file upload section of ini
upload_max_filesize = 800M
post_max_size = 800M
max_file_uploads = 800M

Categories