In the codeigniter framework controller, how can I output an image that cannot be displayed with header ("Content-type: image/jpeg ")?

Source: Internet
Author: User
Tags codeigniter
I wrote it like this: ob_start (); $ this-& amp; gt; ImageResizeNew (& #039; D: 123.jpg& #039;, 240,180 ); (This output image function is okay.) $ imagevariableob_get_contents (); ob_end_clean (); header (& #039; Content-type: imagejpeg & #039;); echo $ imagevar... I wrote it like this:
Ob_start ();
$ This-> ImageResizeNew ('d:/123.jpg ', 240,180); (this output image function is OK)
$ Imagevariable = ob_get_contents ();
Ob_end_clean ();
Header ('content-type: image/jpeg ');
Echo $ imagevariable;
I can display images normally in a non-CI framework, but I cannot display the code in the CI controller. I also asked questions in the CI official forum, but I didn't get a reply, I hope a friend who is familiar with the CI framework can help me solve this problem. I am very grateful.
This Code cannot be changed to the following one.
$ Pic_url = file_get_contents ('d:/123.jpg '); (there is no problem with the picture path)
Header ('content-type: image/jpeg ');
Echo $ pic_url;

Reply content:

I wrote it like this:
Ob_start ();
$ This-> ImageResizeNew ('d:/123.jpg ', 240,180); (this output image function is OK)
$ Imagevariable = ob_get_contents ();
Ob_end_clean ();
Header ('content-type: image/jpeg ');
Echo $ imagevariable;
I can display images normally in a non-CI framework, but I cannot display the code in the CI controller. I also asked questions in the CI official forum, but I didn't get a reply, I hope a friend who is familiar with the CI framework can help me solve this problem. I am very grateful.
This Code cannot be changed to the following one.
$ Pic_url = file_get_contents ('d:/123.jpg '); (there is no problem with the picture path)
Header ('content-type: image/jpeg ');
Echo $ pic_url;

Before using your image method, run the following ob_clean command to clear the ob cache, because the framework may have input content to the buffer before you use this method.

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.