Ankur,
If by 'path ambiguity' you mean that your image files are stored outside
your webroot, then i think i can at least lead you in the right direction.
I use a controller action to output an image from the file system. The
easiest way to do this is to grab ahold of the response object from within
your controller action and set the appropriate headers and content for the
media you want to output.
Here's my controller file:
<?php
class ImageController extends Zend_Controller_Action
{
public function indexAction()
{
$this->_helper->layout->disableLayout();
$this->_helper->ViewRenderer->setNoRender();
$file = '/path/to/file';
$info = getimagesize($file);
$mimeType = $info['mime'];
$size = filesize($file);
$data = file_get_contents($file);
$response = $this->getResponse();
$response->setHeader('Content-Type', $mimeType, true);
$response->setHeader('Content-Length', $size, true);
$response->setBody($data);
$response->sendResponse();
die();
}
}
I purposefully included the beginning php tag so that you would see that I
omitted the closing tag. This is good practice all the time, but invaluable
here. An additional whitespace following a closing tag in this instance
would result in the image not appearing in the browser.
getimagesize(), filesize(), and file_get_contents() you are most likely
already familiar with. If not, take a quick trip to php.net for some more
info. (fyi, the name getimagesize is misleading. it does more than that.)
Hope this helps.
-Mike
The only rea
On Mon, Dec 8, 2008 at 1:20 AM, ankuraeran <[EMAIL PROTECTED]> wrote:
>
> I am newbie to ZF. I could successfully create file upload action but due
> to
> some path abbiguity I am unable to display that uploaded image in browse.
> The path where I put the uploaded image is
>
> <myapplication>/data/uploads/
>
> Will anybody please guide me how to access the image in template.
>
> Regards,
> Ankur
> --
> View this message in context:
> http://www.nabble.com/display-images-tp20890555p20890555.html
> Sent from the Zend Framework mailing list archive at Nabble.com.
>
>