Home  >  Q&A  >  body text

Increase file upload size in Apache configuration

Hello everyone! I'm struggling with this configuration issue because I'm trying to increase the file upload size capacity in the Apache configuration but don't know how to do it exactly. I found this article discussing this but would like to know the correct way to change .htaccess.

https://brightwhiz.com/increase-file-upload-size-apache/

I'm trying to solve the problem of not being able to upload files larger than 5MB in php (laravel), so I found this solution in this article. What is the correct way to configure my .htaccess to do this?

I have tried these configurations

<IfModule mod_rewrite.c>
    <IfModule mod_negotiation.c>
        Options -MultiViews -Indexes
    </IfModule>

    RewriteEngine On

    # Handle Authorization Header
    RewriteCond %{HTTP:Authorization} .
    RewriteRule .* - [E=HTTP_AUTHORIZATION:%{HTTP:Authorization}]

    # Redirect Trailing Slashes If Not A Folder...
    RewriteCond %{REQUEST_FILENAME} !-d
    RewriteCond %{REQUEST_URI} (.+)/$
    RewriteRule ^ %1 [L,R=301]

    # Send Requests To Front Controller...
    RewriteCond %{REQUEST_FILENAME} !-d
    RewriteCond %{REQUEST_FILENAME} !-f
    RewriteRule ^ index.php [L]

    <Directory "/var/www/html/assets">
        LimitRequestBody 67108864
    </Directory>
</IfModule>
<IfModule mod_rewrite.c>
    <IfModule mod_negotiation.c>
        Options -MultiViews -Indexes
    </IfModule>

    RewriteEngine On

    # Handle Authorization Header
    RewriteCond %{HTTP:Authorization} .
    RewriteRule .* - [E=HTTP_AUTHORIZATION:%{HTTP:Authorization}]

    # Redirect Trailing Slashes If Not A Folder...
    RewriteCond %{REQUEST_FILENAME} !-d
    RewriteCond %{REQUEST_URI} (.+)/$
    RewriteRule ^ %1 [L,R=301]

    # Send Requests To Front Controller...
    RewriteCond %{REQUEST_FILENAME} !-d
    RewriteCond %{REQUEST_FILENAME} !-f
    RewriteRule ^ index.php [L]
</IfModule>

<Directory "/var/www/html/assets">
    LimitRequestBody 67108864
</Directory>


P粉512526720P粉512526720314 days ago779

reply all(1)I'll reply

  • P粉957723124

    P粉9577231242023-11-12 09:03:36

    The upload_max_filesize and post_max_size settings in php.ini need to be changed to support files larger than php's default allowed size. < /p>

    Set upload_max_filesize to the maximum size of the file that needs to be uploaded.

    Set memory_limit to the amount of memory required to run the php script, and set max_execution_time to the time in seconds required to run the script.

    upload_max_filesize=30M
    post_max_size=31M
    memory_limit = 100M
    max_execution_time = 120

    reply
    0
  • Cancelreply