Search code examples
phpwordpress.htaccessuploadfilesize

Increasing the upload size in WordPress


I wanted to increase the file upload size limit in wordpress without editing php.ini So I tried adding .htaccess to the wp-content/uploads directory with rules like these:

php_value upload_max_filesize 10M
php_value post_max_size 20M
php_value memory_limit 32M

This doesn't work in wp-content/uploads, the upload max is still 2MB This does work if I put this in the websites .htaccess file though.

Why won't this work if I just put the htaccess in the uploads directory? Are there any risks in increasing the upload size for the entire site?


Solution

  • .htaccess won't work unless the PHP script handling the upload exists at wp-content/uploads/ (which it does not). Placing it in that folder does not have the result you may expect because it only impacts scripts located in that folder.

    You might try placing .htaccess file into /wp-admin/ which will change upload settings for all files handled inside the admin PHP scripts.

    Unclear from your post where else users may be uploading files... are you using upload forms in your public-facing website? If so, you may not want to update the settings server-wide. If not, I see no big risks in making the change.