Home > Backend Development > PHP Problem > What should I do if php cannot handle images that are too large?

What should I do if php cannot handle images that are too large?

藏色散人
Release: 2023-03-14 07:02:01
Original
2250 people have browsed it

Solutions to the problem that PHP cannot handle images that are too large: 1. Adjust the memory allocation size of PHP, with code such as "ini_set("memory_limit", "512M");"; 2. Modify the security restrictions.

What should I do if php cannot handle images that are too large?

#The operating environment of this article: Windows7 system, PHP7.1, Dell G3.

What should I do if php cannot handle images that are too large?

PHP large picture operation causes memory crash and timeout problems

Projects sometimes need to collect pictures and perform post-collection processing, such as: generating thumbnails, cropping, Resize etc.

Collection is affected by network and system performance, and often exceeds PHP's default response time limit (30s). For this reason, an acceptable response time should be set before operating functions that may take a long time:

set_time_limit(0);//0 means no time limit.

After the collection is completed, operate the image and other files, such as generating image thumbnails, etc. If the collected file is relatively large (or the original picture uploaded by the camera has not been cropped and compressed), memory problems will occur. Insufficient error:

At this time, the memory allocation size of PHP needs to be adjusted:

ini_set("memory_limit", "512M"); //默认貌似是128M
Copy after login

Some server environments may have security restrictions, which cannot be done at this time To modify through code, you need to modify the

memory_limit = 128M
Copy after login

option in the PHP.ini file to make changes. This memory size refers to the performance configuration of the server where it is located and should not be too large.

Recommended learning: "PHP Video Tutorial"

The above is the detailed content of What should I do if php cannot handle images that are too large?. For more information, please follow other related articles on the PHP Chinese website!

Related labels:
php
source:php.cn
Statement of this Website
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
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template