Get the App
SLTechnology News&Howtos  ›  Development  › 

How to solve the problem that php imagepng can't output?

Shulou Source: shulou.com Published: 2022-06-03 14:47:34 11月14日 Update

How to solve the problem that php imagepng can not output, I believe that many inexperienced people are at a loss about this. Therefore, this paper summarizes the causes and solutions of the problem. Through this article, I hope you can solve this problem.

The solution that php imagepng can not output: 1, save the file without BOM format; 2, define header and empty the cache, such as "header ('Content-Type: image/png');".

This article operating environment: windows7 system, PHP7.1 version, DELL G3 computer

What if the php imagepng output is not available?

The problem that the output picture of PHP ImagePng () cannot be displayed in the browser.

Take the randomly generated CAPTCHA code as an example. If you want to successfully output a picture to a browser, you must pay attention to two things:

Private function captcha () {ob_clean (); session_start (); header ('Content-Type: image/png'); $image=imagecreatetruecolor (100,30); / / background color is white $color=imagecolorallocate ($image, 255,255,255); imagefill ($image, 20,20, $color) $code=''; for ($iBoth / I

Tags: Output problem storage code content picture location file method more format browser storage browsing success helplessness for this method reason for this Apple Docker Huawei Linux macOS MariaDB Microsoft MySQL NVidia OPPO Reno MariaDB OPPO Reno Shulou Information Docker Shulou Technology