Outputing images from a file within joomla. Topic is solved

Discussion and education for beginner / novice programmers interested in embarking on the development process to take advantage of the extensible nature of the Joomla! CMS.

Moderators: tjay, seadap, Rogue4ngel, matthewhayashida

Forum rules
Post Reply
stevfletchcom

Outputing images from a file within joomla.

Post by stevfletchcom » Tue Oct 23, 2007 1:05 am

I am writing component that will be used for selling digital photography.  I have written the module to store the original files in a secure non web accessible directory.  I have a function being called by the controller.php which sends the image to the browser. 

The function sends two headers to the browser.  Then the data.
header("Content-Type: image/jpeg",TRUE);
header('Content-Disposition: attachment; filename="' . $this->name . '.jpg"',TRUE);
echo file_get_contents($this->path_to_file);

However it only outputs the filename and in the download link it tells the browser an html document is coming.

If any one can tell me how to tell the browser that it's just a jpeg and then send it I would be very appreciative.

Thank you

Fletch

Post Reply