0

I am creating a project in Yii. I am having table as Dnymedia with fields as,

Dnymedia

-mediaId

-mediaPath

-contentTitleId

Suppose I have media path stored as="F:\Documents and Settings\All Users\Documents\My Pictures\Sample Pictures"

How do I display this image as output? I don't need to display it in view. I just want to display the image as output of the controller's action in Yii.

1
  • if you got your answer please accept it, or let me know if any question Commented Dec 19, 2012 at 8:27

2 Answers 2

1

instead of read file use file_get_contents

header('Content-Type: image/jpeg');
echo file_get_contents('F:\Documents and Settings\All Users\Documents\My Pictures\Sample.jpg');
die;
Sign up to request clarification or add additional context in comments.

Comments

0
This worked for me.Please check it.

public function actionTest()
    {
        header('Content-Type: image/jpeg');
        readfile('http://localhost/myAppetite/images/bodyBg.jpg');
         die;
    }

1 Comment

Sir i had tried as above. But its not displaying image,just thumbnail is displayed.....

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.