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.
#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
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
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
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!