Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

Php can't handle too big pictures. How to solve it?

2025-01-21 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Development >

Share

Shulou(Shulou.com)06/02 Report--

This article introduces the relevant knowledge of "php can't handle too big pictures". In the operation of actual cases, many people will encounter such a dilemma. Next, let the editor lead you to learn how to deal with these situations. I hope you can read it carefully and be able to achieve something!

Php can not handle too large pictures of the solution: 1, the PHP memory allocation size adjustment, such as "ini_set (" memory_limit "," 512m ");"; 2, modify the security restrictions.

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

What if php can't handle too big pictures?

The problem of memory corruption and timeout caused by PHP large picture operation

The project sometimes needs to collect pictures and process them after collection, such as generating thumbnails, cutting, resizing and so on.

Collection is affected by network and system performance and often exceeds the default response time limit of PHP (30s). Therefore, you should set an acceptable response time before a function that may take a long time to operate:

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

After the collection is completed, manipulate the image and other files, such as generating image thumbnails, etc. If the captured file is relatively large (or the original image uploaded by the camera is not cropped and compressed), there will be an error of insufficient memory:

At this point, you need to adjust the memory allocation size of PHP:

Ini_set ("memory_limit", "512m"); / / the default seems to be 128m

Some server environments may have security restrictions that cannot be modified by code at this time, so you need to modify the

Memory_limit = 128m

Options are changed. This memory size refers to the server performance configuration and should not be too large.

This is the end of the content of "php can't handle too big pictures". Thank you for your reading. If you want to know more about the industry, you can follow the website, the editor will output more high-quality practical articles for you!

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Development

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report