PHP cannot echo images under Linux

Source: Internet
Author: User
This string of code, cannot display the picture in the Linux environment
$img_url = $_GET['img'];$content = file_get_contents($img_url);header('Content-Type: image/jpeg; charset=UTF-8');echo $content;

Linux Environment Access address demo (there is a problem)
MAC Environment Access address demo (normal)
Win off the machine will not post (normal)

I've added no errors before this string error_reporting(E_ALL);ini_set("display_errors","On");die; of code,
Check the Linux environment allow-url-fopen for on , and can print_r come out, the same content 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 of characters does not make much sense, the interception of a section of the head posted up.

Also add a phpinfo for everyone to view

Reply content:

This string of code, cannot display the picture in the Linux environment

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

Linux Environment Access address demo (there is a problem)
MAC Environment Access address demo (normal)
Win off the machine will not post (normal)

I've added no errors before this string error_reporting(E_ALL);ini_set("display_errors","On");die; of code,
Check the Linux environment allow-url-fopen for on , and can print_r come out, the same content 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 of characters does not make much sense, the interception of a section of the head posted up.

Also add a phpinfo for everyone to view

This problem is resolved at three o'clock last evening, added before the code output, ob_clean there will be unexpected output in thinkphp debug mode, but what this output is not yet found, and this unexpected output is only available under Linux, suspect that there is a problem between the framework and the system configuration.

Normally, you should be able to output images. Under Windows, I tested without problems. Thinkphp may have some application to the OB cache, clean it up, or there may be a problem with the output binary stream directly in the browser.

Less expansion
Freetype,jpegsrc,libpng, try it on.

Header (' content-type:image/jpeg; Charset=utf-8 ');
This line removes charset=utf-8.
Header (' Content-type:image/jpeg ');

Look, LZ's corresponding head is Content-Type: image/jpg , should be Content-Type: image/jpeg .

  • Large-Scale Price Reduction
    • 59% Max. and 23% Avg.
    • Price Reduction for Core Products
    • Price Reduction in Multiple Regions
    undefined. /
    Connect with us on Discord
    • Secure, anonymous group chat without disturbance
    • Stay updated on campaigns, new products, and more
    • Support for all your questions
    undefined. /
    Free Tier
    • Start free from ECS to Big Data
    • Get Started in 3 Simple Steps
    • Try ECS t5 1C1G
    undefined. /

    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.