How to set upload_max_filesize in .htaccess?

To set the upload_max_filesize directive in an .htaccess file, you can use the following code:

php_value upload_max_filesize 20M

This will set the maximum allowed size for uploaded files to 20 megabytes. You can change the value to whatever you want, just make sure to include the appropriate unit (B, K, M, or G).

Watch a course Learn object oriented PHP

Note that the .htaccess file must be placed in the directory where the PHP script that handles the file upload is located. If you want to set this directive for your entire website, you can place the .htaccess file in the root directory of your website.

Additionally, you may need to make sure that the AllowOverride directive is set to All in your Apache configuration file (usually located at /etc/apache2/httpd.conf) for the .htaccess file to be recognized and used.

<Directory /path/to/your/website>
    AllowOverride All

Finally, keep in mind that the upload_max_filesize directive is just one of many directives that you can set in an .htaccess file. You can find a list of all available directives at the following URL: