I want to increase the upload size of my PHP scripts.
From some google searches I have learned you do this by changing the upload_max_filesizeparameters in your php.ini.
Unfortunatly I use one.com for webhosting, and it does not give me access to my php.ini.
Can I change this parameter later?
I was thinking of adding a second php.ini or to change the parameter on the index page.
You can use .htaccess with these code:
php_value upload_max_filesize 30M // Set upload max filesize to 30MB
php_value post_max_size 30M // Set post max size to 30MB
Note
Your provider has to be enabled Dynamic Shared Object (DSO) Support for using php_value! Very technical documentation can you find here: http://httpd.apache.org/docs/2.4/dso.html
You can change through your .htaccess if you are using Apache. Add this line to your .htaccess
php_value upload_max_filesize 100M
Related
I have a PHP 5.5 application running on Google App Engine. It's based on the CodeIgniter framework. Recently I started needing to upload files more than 8 MB.
I have been getting the following error
PHP Warning: POST Content-Length of 8501809 bytes exceeds the limit of 8388608 bytes in Unknown on line 0
I edited php.ini (which is in the same directory as app.yaml), but it doesn't seem to impact the maximum upload size.
post_max_size = "16M"
upload_max_filesize = "16M"
memory_limit = "128M"
Is there somewhere else I should be setting the max_size? Any other fields?
Thanks!
I'm using this in my .htaccess file (this works well on shared hosting where you might not be able to change php.ini):
## I need more memory to upload large image
<IfModule mod_php5.c>
php_value memory_limit 256M
php_value post_max_size 50M
php_value upload_max_filesize 50M
</IfModule>
further: in Codeigniter you can set filesize preference in your config.php file: see here
The PHP runtime Directives documentation may be useful. As you indicated, php.ini file should be in the same directory as your app.yaml. I'd sugest specifically looking at the file_uploads and max_file_uploads values. (Note that the default for each is 0, try setting it to 1).
I added below in php.ini (same place where app.yaml is located) it worked
post_max_size = "16M"
upload_max_filesize = "16M"
memory_limit = "128M"
I was wondering if you can set the post_max_size only for a specific page or function (in the php.ini)?
You can set it in the .htaccess
php_value upload_max_filesize 4M
php_value post_max_size 4M
but it doesn't work for a specific page. Also the ini_set() doesn't work for a specific page.
Any suggestions?
Not possible, unfortunately. post_max_size (and upload_max_filesize) are used before your script is started, so the only way to set them is in .htaccess or php.ini.
upload_max_filesize cannot be changed at runtime (using ini_set).
upload_max_filesize could not be set using ini_set(). The "official" list states that it is PHP_INI_PERDIR
You cannot change the upload_max_filesize at runtime. If you want custom limits for different parts of your app/website you have to set the upload_max_filesize & post_max_size to the maximum value that you want to allow, and after that you have to manually force lower limits with function filesize()
for example: you set upload_max_filesize & post_max_size at 100M, and you can manually reject an upload larger that 50M at a specific page/function by checking the size of the file
There are 3 places you can set it:
php.ini for globally on all pages
.htaccess and php script for local website/ instance.
try removing your .htaccess and see if it reads from the php.ini.
Just remember to also restart your server after changing the php.ini for it to take effect. if using linux, try:
sudo apachectl graceful
If that doesn't work, you will need to check your php code for the max size.
if its in the code, its too broad for me to say what it is.
I am facing a little problem with increasing the Upload_Max_Filesize limit on a clients server. The Upload_Max_Filesize is set to 2M and I need to increase it to at least 10M. There's no php.ini file currently present inside any of the folders albeit I tried creating a php.ini file and then uploaded it to the root folder of the website but that didn't work. I also edited the .htaccess file by putting these two lines inside it but, sadly, that didn't work either:
php_value upload_max_filesize 10M
php_value post_max_size 10M
I have access to the cPanel but it's mentioned inside the PHP Configuration page that:
These PHP configuration settings are customizable by the server administrator. They are listed for reference only.
Please let me know if there's any other way through which I can increase the limit of Upload_Max_Filesize.
You have to contact your host to increase your upload size. I've successfully done it from 5mb to 20mb. You just need to ask.
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've written a php script for uploading file to my website. But it shows some error messages when the file size exceeds 8MB. It came to know that post_max_size and upload_max_filesize are 8M and 4M. I haven't any access to the php.ini file where I hosted my site. I have tried to change the value of these variable using ini_set() and also created an htaccess file for doing the same when the first method became a big flop. This is the code in the htaccess file.
php_value upload_max_filesize 100M
php_value max_execution_time 800
php_value post_max_size 100M
php_value max_input_time 100
php_value memory_limit 120M
Any solution to fix this issue?
You haven't written which SAPI you're using, so this might not always work:
http://php.net/manual/en/configuration.changes.php
You must have PHP configured as Apache module to make your configuration work.
Double check the documentation if this applies for your use-case and double check your server configuration.
Additionally I don't know if writing 120M is correct here or you need to write the number of bytes as a number only.
Next to that there is an alternative approach with ini files per directory, see
http://php.net/manual/en/configuration.file.per-user.php
This might be a workaround for your case.