Changes in file "php.ini" doesn't have any effect - php

I need to upload file more than 100 MB, yii\web\UploadedFile. I am using Linux, CentOS 7.
I did:
check path to php.ini in phpinfo()
add in php_value upload_max_filesize 512M php_value post_max_size 512M in php.ini
restart the LAMP server (lampp) and run phpnfo() to check, but nothing changed. Although php.ini changed.
restart my PC and start the LAMP server, but still no changes in phpnfo().
I have found some solution to add additional.ini.files, but in my phpinfo():
Scan this directory for additional .ini files (none).
I solve this by adding this in file .htaccess:
php_value upload_max_filesize 512M
php_value post_max_size 512M
But the problem still exists. I can't influence file php.ini.

The syntax php_value ... only works in .htaccess files.
To change the value in the php.ini file, you dont' need the php_value part. Search the file for the upload_max_filesize attribute, it's most likely already there and change the value to 512M.
If the line starts with a ; remove it as this comments the line. Do the same for the post_max_size attribute.
If these attributes does not exists yet, add them to the end of the file:
upload_max_filesize = 512M
post_max_size = 512M
After editing the file you need to restart PHP and Apache.

Related

Laravel - File doesnot exist at path [duplicate]

I have try to put these 2 lines
php_value post_max_size 30M
php_value upload_max_filesize 30M
In my root .htaccess file but that brings me "internal server error" message.
php5 is running on the server
I don't have access to php.ini so I think htaccess is my only chance.
Can you tell me where the mistake is?
php_value upload_max_filesize 30M is correct.
You will have to contact your hosters -- some don't allow you to change values in php.ini
If you are getting 500 - Internal server error that means you don't have permission to set these values by .htaccess. You have to contact your web server providers and ask to set AllowOverride Options for your host or to put these lines in their virtual host configuration file.
php_value memory_limit 30M
php_value post_max_size 100M
php_value upload_max_filesize 30M
Use all 3 in .htaccess after everything at last line. php_value post_max_size must be more than than the remaining two.
What to do to correct this is create a file called php.ini and save it in the same location as your .htaccess file and enter the following code instead:
upload_max_filesize = "250M"
post_max_size = "250M"
If your web server is running php5, I believe you must use php5_value. This resolved the same error I received when using php_value.
I also face internal server error message for inserting
php_value upload_max_filesize 5M in my .htaccess file in PHP Laravel Project from c-Panel.
Then I solve it by the following logic -
Create a file named - .user.ini in my Project root Directory
Insert the following code in .user.ini file
upload_max_filesize = 5M
post_max_size = 5M
Both commands are correct
php_value post_max_size 30M
php_value upload_max_filesize 30M
BUT to use the .htaccess you have to enable rewrite_module in Apache config file. In httpd.conf find this line:
# LoadModule rewrite_module modules/mod_rewrite.so
and remove the #.

Codeigniter Php.ini File Location on Shared Server to increase file upload limit [duplicate]

I have try to put these 2 lines
php_value post_max_size 30M
php_value upload_max_filesize 30M
In my root .htaccess file but that brings me "internal server error" message.
php5 is running on the server
I don't have access to php.ini so I think htaccess is my only chance.
Can you tell me where the mistake is?
php_value upload_max_filesize 30M is correct.
You will have to contact your hosters -- some don't allow you to change values in php.ini
If you are getting 500 - Internal server error that means you don't have permission to set these values by .htaccess. You have to contact your web server providers and ask to set AllowOverride Options for your host or to put these lines in their virtual host configuration file.
php_value memory_limit 30M
php_value post_max_size 100M
php_value upload_max_filesize 30M
Use all 3 in .htaccess after everything at last line. php_value post_max_size must be more than than the remaining two.
What to do to correct this is create a file called php.ini and save it in the same location as your .htaccess file and enter the following code instead:
upload_max_filesize = "250M"
post_max_size = "250M"
If your web server is running php5, I believe you must use php5_value. This resolved the same error I received when using php_value.
I also face internal server error message for inserting
php_value upload_max_filesize 5M in my .htaccess file in PHP Laravel Project from c-Panel.
Then I solve it by the following logic -
Create a file named - .user.ini in my Project root Directory
Insert the following code in .user.ini file
upload_max_filesize = 5M
post_max_size = 5M
Both commands are correct
php_value post_max_size 30M
php_value upload_max_filesize 30M
BUT to use the .htaccess you have to enable rewrite_module in Apache config file. In httpd.conf find this line:
# LoadModule rewrite_module modules/mod_rewrite.so
and remove the #.

PHP upload_max_filesize not obeyed

PHP /etc/php.ini is not obeying upload_max_filesize
Details:
using <?php echo phpinfo(); ?> I can see that the 'Loaded Configuration file' is /etc/php.ini
Within this file I have the values:
file_uploads = On
upload_max_filesize = 12M
post_max_size = 12M
BUT
the phpinfo(); shows upload_max_filesize 2M
After restarting Apache serveral times this value is never obeyed whatever I change the upload_max_filesize and max_post_size.
I have worked around this issue by using a .htaccess directive
php_value upload_max_filesize 12M
php_value post_max_size 12M
This has allowed the upload value to be changed and the PHPINFO() now shows the value correctly.
Directive Local Value Master Value
upload_max_filesize 12M 2M
The question is: why is the /etc/php.ini file not being obeyed in the first place?
Running CentOs 5.4 , php 5.3.29
Searched (grep -inr '2M' *) in /etc/php.d/* with nothing found.
Why is it not listening to the main php.ini file which it says it's using?
Already looked at
PHP upload_max_filesize
and
Changing upload_max_filesize on PHP
on SO with no success.
--UPDATE--
Search grep -inr 'upload_max_filesize in /etc/*.ini and .conf with only the 12M value being returned.
Searched /etc/httpd/conf/ /etc/httpd/conf.d/ and obviously the root of the virtual host. No special setup in virtual hosts with grep returning 0 results.
Additional .ini files parsed
/etc/php.d/bcmath.ini, /etc/php.d/curl.ini, /etc/php.d/dom.ini, /etc/php.d/fileinfo.ini,
/etc/php.d/gd.ini, /etc/php.d/intl.ini, /etc/php.d/json.ini, /etc/php.d/ldap.ini,
/etc/php.d/mbstring.ini, /etc/php.d/mcrypt.ini,
/etc/php.d/mysql.ini, /etc/php.d/mysqli.ini, /etc/php.d/pdo.ini, /etc/php.d/pdo_mysql.ini, /etc/php.d/pdo_sqlite.ini,
/etc/php.d/phar.ini, /etc/php.d/posix.ini, /etc/php.d/soap.ini, /etc/php.d/suhosin.ini, /etc/php.d/sysvmsg.ini, /etc/php.d/sysvsem.ini, etc/php.d/sysvshm.ini,
/etc/php.d/wddx.ini, /etc/php.d/xdebug.ini, /etc/php.d/xmlreader.ini, /etc/php.d/xmlwriter.ini,
/etc/php.d/xsl.ini, /etc/php.d/zip.ini
If you examine the first few lines of the phpinfo() you can know
which php.ini is loaded.(courtesy #Raptor)
In your question you have mentioned that /etc/php.ini is indeed the one loaded.
In that case there is a chance that your httpd.conf contains something like below :
php_value upload_max_filesize somevalue
This is a global value which will be applied for all the sites.
I guess it may well override the php.ini settings.
I had the .htaccess in the root of website overriding this value from php.ini.
Try to set in your htaccess file. May be this might help you guys. It's working for me
php_value post_max_size 30M
php_value upload_max_filesize 25M
php_value upload_max_size 25M
I lost quite a bit of time trying to figure this out as well. Turns out that this will happen if you are using php-fpm. The php.ini file will be read, phpinfo() will tell you that it's been read, but the max filesize value (as well as a few others) will be ignored.
I experienced this with a Centos8 install, and it took me far too long to notice that it was using php-fpm instead of mod_php, so all the arguments to mod_php were being ignored.
Your options are to either install mod_php or just configure php-fpm properly (better).

echo $_FILES['data-file']['tmp_name']; die; file name is not printed if size more then 128M in PHP

I try to upload file of 300 MB. but not uploaded and now display any error.
variables value in php.ini file is
post_max_size 800M
upload_max_filesize 750M
memory_limit 2048M
max_execution_time 17100
max_input_time 17100
if i try to print tmp name of file by echo $_FILES['data-file']['tmp_name']; die; Nothing display page redirecto to home. but for less then 128M it show /tmp/phpShle like that.
If you are on LAMP make sure you are editing right php.ini file. In LAMP you will find cli related php.ini and php-apache related php.ini. To make above scenarios of file upload possible, you will need to edit php-apache php.ini file which is in /etc/php5/apache2/ and also restart apache service.
If you are on WAMP, it has only one php.ini and WAMP is automatically restarting services after editing file. So it should work.
-Or-
You can write a .htaccess file in web home directory.
RewriteEngine on
php_value post_max_size 300M
php_value upload_max_filesize 300M
Please write this on .htaccess.
<IfModule mod_php5.c>
php_value post_max_size 256M
php_value upload_max_filesize 256M
php_value memory_limit 500M
</IfModule>
This might help you. Cheers :)
My proble is solved. I need to set these variable on modsec2.user.conf file
SecRequestBodyLimit 1073741824
SecRequestBodyNoFilesLimit 1073741824
This is a apache server file. and error was shown on Apache error log.

Why does .htaccess or php.ini overriding /etc/php.ini not work?

I want to adjust the post_max_size and upload_max_filesize without altering /etc/php.ini
PHP Version 5.3.27
root directory: /var/www/html/my_site
Here are the things that I did:
I added php.ini under html directory (didn't work)
memory_limit = 96M
post_max_size = 64M
upload_max_filesize = 64M
I added .htaccess file under html directory (didn't work)
php_value upload_max_filesize 64M
php_value post_max_size 64M
I also added both of them under /my_site directory and none of them worked
Everytime I add each of them I restart the server
I also changed php.ini to php5.ini
I also changed
php_value
to
php5_value
Adjusted permission issues
What went wrong?
Many shared hosts restrict the flags you can use in your .htaccess, and upload_max_filesize/post_max_size are common ones. If you're on a shared host contact tech support to confirm this.

Categories