Good evening, I want the pictures on the site to open through a handler, like this: http://yiiframework.ru/forum/download/file.php?avatar=5301_1377506680.png

how to implement it?

I tried it differently: I write img src through a het and transfer the image name, and in the handler I simply tried the echo "obsalyutny url to the image", zero result, tried to change the content type header('Content-Type: image/jpeg'); also zero (

Tell me please.

    1 answer 1

     <?php echo '<img src="/images/'.$_GET['avatar'].'" alt=""/>'; 

    I do not know what you have there. But it works great for me.

    UPD: so they would have said it right away.

    output code

     <?php echo '<img src="file.php?avatar=image.png" alt=""/>'; 

    file code file.php

     <?php header("Content-Type: image/jpeg"); readfile($_GET['avatar']); 
    • Well, yes, if you open it separately in the browser, it works for me too, and if you specify this URL in src, then no. I want, as here yiiframework.ru/forum/viewtopic.php?f=3&t=18699 made display avatar <img src = " yiiframework.ru/forum/download/… "> - bemulima
    • > I want how here Why do you consciously want to do badly? PS No, I do not want to say that "there" is bad. They may have their own considerations. But it is necessary to proceed from the fact that without sufficient motivation and intelligible explanations such a way is obviously bad. - user6550 pm
    • Updated the answer. - Bastian
    • I am trying through the handler to change the direct url of the image in such a way. if the real URL is images / name.jpg then after the handler for example newurl / newname.jpg. - bemulima
    • @rnddev, thanks for the help! - bemulima pm