upload_max_filesize, php.ini, and Google App Engine - php

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"

Related

Issues with wordpress Max upload size

So I have wordpress plugin that sets my max upload file size and currently it is set to 536mb. (which should be more then enough) But still when I try to upload 3,3 mb .xml file I get an error:
The uploaded file exceeds the upload_max_filesize directive in php.ini.
When trying to Upload
I had the same problem. I tried editing the wp-config.php file and added:
define('WP_MEMORY_LIMIT', '32M');
edited the .htaccess and added:
php_value upload_max_filesize 32M
php_value post_max_size 32M
php_value max_execution_time 300
php_value max_input_time 300
none of the above seemed to work for me. I also tried locating the php.ini file on my directory but couldn't find it.
I created my php.ini file and added:
php_value upload_max_filesize 64M
php_value post_max_size 32M
still nothing changed.
MY SOLUTION
I went back to my cPanel home page and located the MultiPHP INI Editor under the SOFTWARE tab, selected my domain name from the dropdown menu and opened its PHP configuration, scrolled down to the bottom and located the upload_max_filesize directive and changed it from 2MB to the size i want.
That solved my problem. Hope it works for you as well
Open the php.ini file on your hosting server (Typically located somewhere like:
/usr/bin/php5/bin/php.ini in Linux) and adjust the following lines:
; Maximum allowed size for uploaded files.
upload_max_filesize = 536M
; Must be greater than or equal to upload_max_filesize
post_max_size = 536M

PHP ERR_CONNECTION_RESET error with FILE UPLOAD more than 8MBs

My server settings are as below:
max_execution_time : 0
max_input_time : -1
memory_limit : 128M
upload_max_filesize : 128M
post_max_size : 128M
still I am getting ERR_CONNECTION_RESET while uploading a file (size > 8MBs). Not even var_dump($_FILES); is working. Any file size below 8MBs is uploading easily. Not sure where I am wrong. Please suggest.
Although all the server configurations are set still I am getting the same issue.
Check your php settings for both of these:
upload_max_filesize = 64M
post_max_size = 64M
The problem in my case is the file I was trying to upload.
That PDF file was corrupted. I repaired the PDF file with some online PDF file repairing tool and it worked fine.
In case if you have shared server, you can add php.ini file and add following lines to it.
memory_limit = 1024M
max_input_vars = 2000
upload_max_filesize = 300M
post_max_size = 300M
max_execution_time = 990
This will work fine.
In additional to the above, make sure that
LimitRequestBody
in your .htaccess file is set properly or disabled altogether. 0 means unlimited
Docs here
Apache LimitRequestBody Directive

Increase upload size without acces to php.ini

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

Can't reset the values of upload_max_filesize and post_max_size using htaccess file

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.

POST Content-Length exceeds the limit

I get similar errors in my error_log in php when users are uploading their files
PHP Warning: POST Content-Length of 11933650 bytes exceeds the limit of 8388608 bytes in Unknown on line 0
In my php.ini (created custom ini file in public_html) would this solve this problem, how much would I have to set it to around 1GB? I am going to change my settings to this in php.ini, will it solve the problem?
upload_max_filesize = 1000M ;1GB
post_max_size = 1000M
What would I set the 'memory_limit' limit to.
Also would this be correct in my script to check file uploaded size is <1GB
if($_FILES["uploadedfile"]["size"]<1000000)
8388608 bytes is 8M, the default limit in PHP. Those changes to php.ini should indeed solve the problem (make sure your restart your Apache server after making them).
Memory limit shouldn't need to be changed here.
I suggest that you should change to post_max_size from 8M to 32M in the php.ini file.
you just setting at php.ini
then set :
upload_max_filesize = 1000M;
post_max_size = 1000M;
then restart your xampp..
Check the image
Try pasting this to .htaccess and it should work.
php_value post_max_size 2000M
php_value upload_max_filesize 2500M
php_value max_execution_time 6000000
php_value max_input_time 6000000
php_value memory_limit 2500M
post_max_size should be slightly bigger than upload_max_filesize, because when uploading using HTTP POST method the text also includes headers with file size and name, etc.
If you want to successfully uppload 1GiB files, you have to set:
upload_max_filesize = 1024M
post_max_size = 1025M
Note, the correct suffix for GB is G, i.e. upload_max_filesize = 1G.
No need to set memory_limit.
In Some cases, you need to increase the maximum execution time.
max_execution_time=30
I made it
max_execution_time=600000
then I was happy.
There might be more than just one php.ini file. For example, when using WAMP there are 2 php.ini files in following directories:
C:\wamp\bin\apache\apache2.4.9\bin
C:\wamp\bin\php\php5.5.12
You need to edit the first one.
I disagree, but the solution to increase the file size in php.ini or .htaccess won't work if the user sends a file larger than allowed by the server application.
I suggest validating this on the front end. For example:
$(document).ready(function() {
$ ('#your_input_file_id').bind('change', function() {
var fileSize = this.files[0].size/1024/1024;
if (fileSize > 2) { // 2M
alert('Your custom message for max file size exceeded');
$('#your_input_file_id').val('');
}
});
});
If you are using Php 5.6.X versions in windows using Wamp, then file location may be in,
C:\Windows\php.ini
Just try with
post_max_size = 100M;
Try to do changes in Apache one. By that your Wamp/XAMP load .ini file
If you are using Laravel and using artisan:serve for running Laravel project you create php.ini in your public directory, then you can specify your configuration.
file_uploads = On
max_execution_time = 300
post_max_size = 20480M
upload_max_filesize = 20480M

Categories