dimanche 29 mars 2015

php return image from url

I want to return an image over an URL like http://ift.tt/1nSnYrV. I have my URL http://ift.tt/1EovAhh, which calls an action on controller. The controller get some data (name, id, etc.) from database and also a binary string of the image content.


On the frontend site, i have my img tag, where i want to call the url in my src attribute.



<img src="http://ift.tt/1EovAhh">


Some more information, i use slim PHP Framework and my server is an ubuntu 13.x system (vagrant etc.). I am an typically frontend developer and dont have good skills @ PHP.


Following snippets works:



$file = fopen($name, 'wb');
fwrite($file, $binaryData);
fclose($file);


but I dont want to generate files in a directory. Is this possible?


EDIT: Content-Type and Content-Length Headers are set, that is not the problem.


Aucun commentaire:

Enregistrer un commentaire