简体   繁体   中英

File upload fails laravel

so I created simple form to upload files and dd the $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

this is my php.ini file inside laravel

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. The problem is in the nginx config.

You must increase the client_max_body_size . The default value of it is 1 MB per file.

Add the following in your default.conf of your nginx project:

server {
    ...

    client_max_body_size 128M;

    ...
} 

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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