简体   繁体   English

文件上传失败 laravel

[英]File upload fails laravel

so I created simple form to upload files and dd the $request->file所以我创建了简单的表单来上传文件并 dd $request->file

<form 
    action="/videos" 
    method="post" 
    enctype="multipart/form-data"
    id="upload_form"
    name="upload_form"
    >
        @csrf
        <input type="file" name="avatar" />
        <input type="submit" value="submit" />
    </form>

dd($request->file('avatar');

if the video is above 1 mb but less than 8 mb it get's uploaded with error 1 and a size of 0 mb if the video is above 8 mb I get an error Illuminate\Http\Exceptions\PostTooLargeException PHP Warning: POST Content-Length of 21712952 bytes exceeds the limit of 8388608 bytes in Unknown on line 0如果视频大于 1 mb 但小于 8 mb,则会上传错误 1,大小为 0 mb 如果视频大于 8 mb,则会收到错误Illuminate\Http\Exceptions\PostTooLargeException PHP Warning: POST Content-Length of 21712952 bytes exceeds the limit of 8388608 bytes in Unknown on line 0

this is my php.ini file inside laravel这是我在 laravel 中的 php.ini 文件

post_max_size = 100M
; upload_max_filesize = 60M
variables_order = EGPCS
max_execution_time = 3600s
memory_limit = 100M
upload_max_filesize = 60M

Your php.ini config is fine.您的 php.ini 配置很好。 The problem is in the nginx config.问题出在 nginx 配置中。

You must increase the client_max_body_size .您必须增加client_max_body_size The default value of it is 1 MB per file.它的默认值为每个文件1 MB

Add the following in your default.conf of your nginx project:在 nginx 项目的default.conf中添加以下内容:

server {
    ...

    client_max_body_size 128M;

    ...
} 

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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