首页  >  问答  >  正文

增加 Apache 配置中的文件上传大小

大家好!我在这个配置问题上苦苦挣扎,因为我试图增加 Apache 配置中的文件上传大小容量,但不知道如何准确地做到这一点。我发现这篇文章讨论了这一点,但想知道更改 .htaccess 的正确方法。

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

我正在尝试解决 php (laravel) 中无法上传大于 5MB 的文件的问题,因此我在本文中找到了此解决方案。配置我的 .htaccess 来执行此操作的正确方法是什么?

我已经尝试过这些配置

<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 天前777

全部回复(1)我来回复

  • P粉957723124

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

    需要更改 php.ini 中的 upload_max_filesizepost_max_size 设置,以支持大于 php 默认允许大小的文件。< /p>

    upload_max_filesize设置为需要上传的文件的最大大小。

    memory_limit 设置为运行 php 脚本所需的内存量,并将 ma​​x_execution_time 设置为运行脚本所需的时间(以秒为单位)。

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

    回复
    0
  • 取消回复