PHP cannot echo images in Linux

Source: Internet
Author: User
This code string cannot be displayed in linux. {code ...} access address demo for linux environment (problem) access address demo for mac environment (normal) If win is shut down, it will not be pasted (normal) I have added error_reporting (E_ALL); ini_s... this code string cannot display images in linux

$img_url = $_GET['img'];$content = file_get_contents($img_url);header('Content-Type: image/jpeg; charset=UTF-8');echo $content;

Demo of the access address in the linux environment (problem exists)
Access address demo in mac environment (normal)
If win is shut down, it will not be pasted (normal)

I added this code before.error_reporting(E_ALL);ini_set("display_errors","On");die;No error found,
Checkallow-url-fopenIsonAnd canprint_rThe content is the same as follows:

����JFIF��;CREATOR: gd-jpeg v1.0 (using IJG JPEG v62), quality = 90 ��C     ��C      ��j�"��  ���}!1AQa"q2���#B��R��$3br� %&'()*456789:CDEFGHIJSTUVWXYZcdefghijstuvwxyz��������������������������������������������������������������������������� ���w!1AQaq"2�B����  #3R�br� $4�%�&'()*56789:CDEFGHIJSTUVWXYZcdefghijstuvwxyz��������������������������������������������������������������������������?�����2���}x����bi��f(�IQ߆���]/�?

This string does not make much sense. It captures the header and adds it to it.

Add a phpinfo file for you to view.

Reply content:

This code string cannot display images in linux

$img_url = $_GET['img'];$content = file_get_contents($img_url);header('Content-Type: image/jpeg; charset=UTF-8');echo $content;

Demo of the access address in the linux environment (problem exists)
Access address demo in mac environment (normal)
If win is shut down, it will not be pasted (normal)

I added this code before.error_reporting(E_ALL);ini_set("display_errors","On");die;No error found,
Checkallow-url-fopenIsonAnd canprint_rThe content is the same as follows:

����JFIF��;CREATOR: gd-jpeg v1.0 (using IJG JPEG v62), quality = 90 ��C     ��C      ��j�"��  ���}!1AQa"q2���#B��R��$3br� %&'()*456789:CDEFGHIJSTUVWXYZcdefghijstuvwxyz��������������������������������������������������������������������������� ���w!1AQaq"2�B����  #3R�br� $4�%�&'()*56789:CDEFGHIJSTUVWXYZcdefghijstuvwxyz��������������������������������������������������������������������������?�����2���}x����bi��f(�IQ߆���]/�?

This string does not make much sense. It captures the header and adds it to it.

Add a phpinfo file for you to view.

This problem was solved at three o'clock last night and added before code output.ob_cleanIn the debugging mode of Thinkphp, there will be unexpected output, but this output is not found yet, and this unexpected output will only be available in linux, it is suspected that there is a problem between the framework issue and the system configuration.

Normally, the image can be output. In windows, I have no problem during the test. Thinkphp may have some applications in ob cache. Clear them. Otherwise, the binary stream output directly in the browser may be faulty.

Less Scaling
Install freetype, javassrc, and libpng.

Header ('content-Type: image/jpeg; charset = UTF-8 ');
This line removes charset = UTF-8
Header ('content-Type: image/jpeg ');

After reading it, the corresponding header of lz isContent-Type: image/jpg, It should beContent-Type: image/jpeg.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.