In my content type, my drupal 7 server is stating I have a 'current max limit 8MB' for file uploads. So I cannot change this to 128Mb as I want to.
But my web host php settings allow for 128MB uploads and in my config/media/file-settings I have set an upload of 128 MB uploads. In my settings.php file I have set 'ini_set('memory_limit', '2048M'); ' under PHP settings.
Why is my Drupal site not increasing the upload size, though I have set the increased upload size in all the file settings, the content type settings and php settings file. There is no error message, but also no increase. What have I missed out, or what am I doing wrong? How can I increase the file upload?
Thank you
You could add these lines to your htaccess file in your root directory.
php_value upload_max_filesize 128M
php_value post_max_size 128M
Related
My problem is when I upload a file exceeds the limits I set in the script (5 MB) it shows this warning in the top of the website:
Warning: POST Content-Length of 32485176 bytes exceeds the limit of 20971520 bytes in Unknown on line 0
For example here I uploaded a file more than (30 MB) but when I upload a file more than (5 MB) and less than 30 (or not that large) it doesn't show that warning and shows only the error I wanted from the code :
if($file_size > 5000000) { echo
"<div>
You Can't Upload More than 5MB of the file
</div>";
}
I am working on localhost and this error is appearing every time, I know how to fix it in localhost by modifying php.ini, but the website is online too and this error isn't showing in the website.
Is there a way to limit the uploaded files sizes to (5 MB) and not modifying the php.ini file because I don't think I have the permission from the hosting company to change the apache config for the limits.
I hope my question's clear.
Thanks for helping.
You can change it via .htaccess file in your php file directory...
.htaccess files are stored in the same directory as your .php files are. They modify configuration for that folder and all sub-folders. You simply use them by creating an .htaccess file in the directory of your choice (or modify it if present).
The following should enable you to increase your upload limit (if the server provider allows PHP config changes via .htaccess).
php_value upload_max_filesize 100M
php_value post_max_size 105M
you just settings at php.ini
then set :
upload_max_filesize = 1000M;
post_max_size = 1000M;
then restart your server..
Hello go To You Xampp Directory and then go as follow :-
xampp\php\php (configuration file)
Find for post_max_size (make sure you are at top of file)
then change
post_max_size = 2M To post_max_size 1000M
upload_max_filesize = 8M To upload_max_filesize = 1000M
and now restart you apache server or if still error restart apache , mysql too
Please Let Me know if any concern
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');
?>
I've made a tiny site where my friends can upload songs and some tiny files that they want to but my problem is that files over 5mb fails, as in the browser shows "Connection reset" error.
The max file size set by my server is 2Mb, but i can upload 2.5-3Mb fine
Probably because i overwrote it with .htaccess
But however file uploads over 5Mb they just don't get uploaded at all, as i said earlier browser cannot reach server.
Would this be a server issue? Or an issue in my code? Will i need to change things in order for large uploads to happen?
Also max post size and max file size is set to 40mb in the .htaccess file
Here is the website
http://sharebay.webatu.com/
You can try uploading some files over 7mb, mp3/flac/aac/m4a/wav/
Add these to .htaccess as well (adjust 10M to size in MB that you want):
php_value upload_max_filesize 10M
php_value post_max_size 10M
This assumes you don't have access to php.ini (otherwise it would be better to put there) and that your host does not prohibit htaccess overrides on these values.
If you've already tried that then post more info about your environment. If you are on a shared server it's probably not something you can change too much.
How long the upload takes?
If you have slow upload line then it should take more time then max_execution_time and then apache halts your PHP script.
Change file upload size
You can change it an .htaccess file.
.htaccess files are stored in the same directory as your .php files are. They modify configuration for that folder and all sub-folders. You simply use them by creating an .htaccess file in the directory of your choice (or modify it if present).
The following should enable you to increase your upload limit (if the server provider allows PHP config changes via .htaccess).
php_value upload_max_filesize 70M
php_value post_max_size 80M
php_value memory_limit 90M
php_value max_execution_time 240
php_value max_input_time 240
you can change size according ur need
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
I had uploaded three files to the server in php. Smaller files are uploaded correctly but
when uploading larger files I get an error.
How to upload large files in php?
If the smaller files are uploaded successfully but not the larger files, then most probably the problem is caused by the php.ini settings.
Did you check what is Maximum allowed size for uploaded files defined in your php.ini file? Find the following line in your php.ini file, there you can define the size. For example:
upload_max_filesize = 10M
You have to set your php.ini to accept larger file size: you are interested in two variables i think:
upload_max_filesize // the max size a file can have when uploaded
max_post_size //the max size of a POST call
Look here for reference
As Nicola points out, there are some variables in the php.ini you should look for:
For example, in php.ini:
memory_limit = 384M
post_max_size = 256M
upload_max_filesize = 200M
What Nicola didn't mention is that constraints may also be in place on your web server. If it's nginx for example, you need to make adjustments to the configuration of your virtual host to support larger files ...
For nginx:
client_max_body_size 150m;
For Apache:
The apache webserver has a LimitRequestBody configuration directive that restricts the size of all POST data regardless of the web scripting language in use. Some RPM installations sets limit request body to 512Kb. You will need to change this to a larger value or remove the entry altogether.
increase the memory limit with .htaccess or ini_set() function in php