How to set upload_max_filesize in .htaccess? - php

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 #.

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 #.

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

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.

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