CodeIgniter Forums
Can’t display image in jpg format - Printable Version

+- CodeIgniter Forums (https://forum.codeigniter.com)
+-- Forum: Archived Discussions (https://forum.codeigniter.com/forum-20.html)
+--- Forum: Archived General Discussion (https://forum.codeigniter.com/forum-21.html)
+--- Thread: Can’t display image in jpg format (/thread-2829.html)



Can’t display image in jpg format - El Forum - 08-27-2007

[eluser]Wangringring[/eluser]
I've got a problem about display image in CI.
I don't want to use <img> tab to display image.
Does it have any library in CI?
I just want to display an image. I try to use image_lib() but it didn't work too.

Now I'm trying to use simple code to display image.
My code in View is like this

Code:
header("Cache-control: private");
header("Content-Type: image/jpg");
header("Content-Disposition: inline ;filename=arnon.jpg");
$fn=fopen("images/arnon.jpg","r");
fpassthru($fn);

but It displays not an image. It likes many ramdom-text and special characters like this:
Code:
Oฝฎดs]r๒#๗ฝ=?ถฒณด#๏ฐP% ๋ต˜# ชฒ?๓โมมฌ ‰#JFIF###HHํ Adobe_CM#๎#Adobed€#„ ### # # ### ########## # # # ################

Could anyone suggest me please?


Can’t display image in jpg format - El Forum - 08-27-2007

[eluser]deviant[/eluser]
Try replacing the content type with image/jpeg


Can’t display image in jpg format - El Forum - 08-27-2007

[eluser]Wangringring[/eluser]
When I use this code Out of the CI.(Normal PHP without any framework) It's work properly !!
Code:
header("Cache-control: private");
header("Content-Type: image/jpg");
header("Content-Disposition: inline ;filename=arnon.jpg");
$fn=fopen("images/arnon.jpg","r");
fpassthru($fn);

I don't know why. It seems "fpassthru" didn't work in my CI.
When I use this code without CI, it returns My photo correctly.
But in CI returns Blank page and No any error occured.


Can’t display image in jpg format - El Forum - 08-28-2007

[eluser]Wangringring[/eluser]
I'd like to close this topic. What should I do?


Can’t display image in jpg format - El Forum - 03-23-2011

[eluser]arsenalist[/eluser]
Exact same issue. Any solutions?


Can’t display image in jpg format - El Forum - 03-23-2011

[eluser]InsiteFX[/eluser]
Edit Post Topic Title add [SOLVED]

InsiteFX


Can’t display image in jpg format - El Forum - 03-23-2011

[eluser]arsenalist[/eluser]
Did this thread get spammed?

With every passing day I regret leaving Zend for this.


Can’t display image in jpg format - El Forum - 03-23-2011

[eluser]arsenalist[/eluser]
For any poor guy still stuck using CI, here's the solution:

http://groups.google.com/group/google-chart-api/browse_thread/thread/787027153d2d0330?pli=1