Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 9269697
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 18, 20262026-06-18T15:11:21+00:00 2026-06-18T15:11:21+00:00

I am new to Zend Framework 2 and only know a little basics. I

  • 0

I am new to Zend Framework 2 and only know a little basics. I find it difficult to find a lot of examples as well.

Quesiton: Get BLOB field in database and display it through a controller. For example: http://www.mysite.com/images/2 will retrieve a BLOB from the database and display it to the user as an image so an html tag like <img src="http://www.mysite.com/images/2"/> will display an image.

I normally do it in ASP.NET MVC but have no clue how to do it here. I would be delighted if some one could enlighten me on how to achieve it.

Assume that I have fetched the image from the database.

I managed to find how to return JSON and believe some thing simple like that would work. But couldn’t find the solution. I will also need to send files like that.

public function displayAction()
{
    $id = 10;
    $albumImage = $this->getAlbumImageTable()->getAlbumImage($id);

    if ($albumImages){
        //Show the image $albumImage
        //return JsonModel(array(...)) for json but for image ???
    } else{
        //Show some other image
    }
}

I would be obliged if some one could help.

Thanks in advance.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-18T15:11:22+00:00Added an answer on June 18, 2026 at 3:11 pm

    As of Zend Framework 2.0 to 2.1

    If you want to return an image, simply return the response object filled in with the content: that will tell the Zend\Mvc\Application to entirely skip the Zend\Mvc\MvcEvent::EVENT_RENDER event and go to Zend\Mvc\Application::EVENT_FINISH

    public function displayAction()
    {
        // get image content
        $response = $this->getResponse();
    
        $response->setContent($imageContent);
        $response
            ->getHeaders()
            ->addHeaderLine('Content-Transfer-Encoding', 'binary')
            ->addHeaderLine('Content-Type', 'image/png')
            ->addHeaderLine('Content-Length', mb_strlen($imageContent));
    
        return $response;
    }
    

    This will cause the application to short-circuit to the Zend\Mvc\Event::EVENT_FINISH, which in turn is capable of sending the response to the output.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm new to Zend Framework. I would like to know how to implement zend
im new in PHP and I want to know about PHP Zend Framework. What
I'm new with Zend Framework but i didn't find solution yet. Problem is next:
I'm new to Zend framework and trying to get some insights about code re-usability.
I'm pretty new to Zend Framework thou i am starting to get the gist
I'm just new to Zend Framework. Currently what I'm trying to do is when
I am new to Zend framework. I am having a controller interact with a
I am pretty new to the zend framework and the JQuery helper. I have
I feel my problem is relatively simple. I'm new to the Zend framework and
I'm new to php and zend framework and fill very uncertain about following: For

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.