简体   繁体   中英

Why isn't .htaccess file being edited?

On my website, I have image uploading input field in one of the forms, and in general when I try to upload an image, everything works fine, but in some cases an error occurs in a file processing the form input. When I var_dump $_FILES array, I can observe that all elements of the array except name are empty.

I've noticed that it depends on a file size which is being uploaded. So I decided to edit .htaccess file to increase maximum possible value of uploaded image. .htaccess file is placed in the root directory of my project , I'm using XAMPP.

I wrote these lines in .htaccess:

php_value file_uploads = On
php_value post_max_size = 100000M
php_value upload_max_filesize = 100000M
<Directory />
    AllowOverride All
</Directory>

But it doesn't seem to work. The problem still occurs when I upload a bigger image.

What am I doing wrong? How can I make .htaccess work?

UPD 0: I made some changes to the post

 php_value file_uploads = On php_value post_max_size = 100000M php_value upload_max_filesize = 100000M <Directory /> AllowOverride All </Directory>

The <Directory> container is not valid inside .htaccess files and nor is it required here. The .htaccess file itself is effectively the <Directory> container.

Also, the syntax for setting the PHP config vars is incorrect, there should be no = here. For example:

php_flag file_uploads On
php_value post_max_size 100000M
php_value upload_max_filesize 100000M

Since file_uploads is a boolean, you should really use php_flag , instead of php_value to set this.

Also, whether this works at all is dependent on how PHP is installed. This is valid only if PHP is installed as an Apache module (ie. mod_php).

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM