简体   繁体   中英

413 request entity too large - PHP Vapor Laravel

Locally it works, when it's in production I can't upload the file, it's a CSV that has a size of 6.8mb, it's hosted on vapor. i'm using vue2dropzone component.

在此处输入图像描述

在此处输入图像描述

It can have several reasons.

you should to check:

  • php configuration file (php.ini). upload_max_filesize post_max_size

  • Apache web service configuration like if your server use from apache service (httpd.conf, .htaccess): edit this values:

    post_max_size upload_max_filesize LimitRequestBody

  • Or if your server works with nginx service you can check nginx.conf file. edit this value:

    client_max_body_size

In the documentation , your host indicates that POST requests uploads are capped. With a little overhead from parameters, headers, etc, this means your uploads must be a little under 4.5MB.

File Uploads

Due to AWS Lambda limitations, file uploads made directly to your application backend can only be up to roughly 4.5MB in size. This is a hard limit imposed by AWS, and updating the php.ini configuration file or any other configuration will not raise this limit. Therefore, to ensure your application's users won't receive an HTTP 413 Payload Too Large response, you may validate the file upload size using JavaScript before initiating the file upload to your application's backend.

If your application needs to receive file uploads larger than AWS allows, those files must be streamed directly to S3 from your application's frontend (Browser). To assist you, we've written an NPM package that makes it easy to perform file uploads directly from your application's frontend.

The solution (which is just one of many, you don't have to use their suggestion) mentioned uses the browser-based laravel-vapor package to upload files to a S3-compatible storage. Authentication is done by having your Laravel app create a URL that can used once to upload a file into a S3 storage bucket. That way, you don't store your credentials in the front-end.

Alternatively, if you just want to ingest the CSV file without storing it you could choose to upload it in chunks or perhaps stream it to your backend line-by-line.

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