Home>Article>Backend Development> What should I do if large videos cannot be uploaded using php?

What should I do if large videos cannot be uploaded using php?

爱喝马黛茶的安东尼
爱喝马黛茶的安东尼 Original
2019-09-28 16:42:15 4112browse

What should I do if large videos cannot be uploaded using php?

1. Environment:

CentOS 6.8

nginx 1.8.0

php 7.0.10

2. Background

H5 project based on nginx php. When uploading a video, if the video is too large, the upload will fail.

Related recommendations: "php Getting Started Tutorial"

3. Text

A video is sent to the backend, which requires After two levels:

1, nginx

2, php

Solution=> Modify the configuration item (i.e. the text on the arrow in the picture below):

What should I do if large videos cannot be uploaded using php?

1. Modify nginx configuration

Open nginx.conf and modify:

client_max_body_size 500m;

After restarting nginx, the upload size exceeds 200M video will only report an error:

413 Request Entity Too Large

2. Modify the php configuration

Open php.ini and modify:

upload_max_filesize 500M post_max_size 550M memory_limit 600M

Restart php.

Note: Why upload_max_filesize

For a request to upload a file, the following equation exists:

POST DATA = File Base64 form other project data,

HTTP DATA = HTTP HEAD POST DATA.

The file size is limited by upload_max_filesize,

The size of POST DATA is limited by post_max_size,

The entire HTTP request data will be placed in the memory cache first, that is, the size of HTTP DATA is limited by memory_limit limit.

The above is the detailed content of What should I do if large videos cannot be uploaded using php?. For more information, please follow other related articles on the PHP Chinese website!

Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn