On Jan 18, 2011, at 23:04, pinastro wrote:
> exactly , I am reading about Downloading the image ..
>
> and somehow I am able to display the image too...but it's RAW image
> CONTROLLER :::
>
> function download($id) {
> Configure::write('debug', 0);
> $file = $this->MyFile->findById($id);
> $type= $file['MyFile']['type'];
> $length = $file['MyFile']['size'];
> $nam = $file['MyFile']['name'];
>
> header('Content-type: $type');
> header('Content-length: $length'); // some people reported
> problems
> with this line (see the comments), commenting out this line helped in
> those cases
> header('Content-Disposition: attachment; filename=$nam');
> echo $file['MyFile']['data']; ///WHEN I COMMENT THIS LINE ....
> ONLY FILE LOCATION (database) is PRINTED
>
> //$this->set(compact('file','nam'));
> exit();
> }
>
> VIEW
>
> <?php
> echo "DISPLAY PINASTRO";
> header("Content-type: image/jpg");
> echo print_r((explode("/",$data['MyFile']['data']))); //THIS WAS FOR
> TESTING PURPOSE THOUGH
> ?>
>
>
> not getting how will i use <IMG> tag ???
Read what I wrote again. You'll have two actions in your controller. One, this
download action you've shown us, does nothing other than send the PNG to the
browser. The second one will show a normal CakePHP ctp view file, and in that
view, you'll create an img tag, just as you would to display any other static
image, except that its src (I think I wrote href before but I meant src) will
point not to a static file on disk but to the URL of your download action (i.e.
"$this->link(array('action' => 'download', ...))").
Try getting the download action working first, so that when you call it up in
the browser, it displays the image by itself. If it's not working, maybe read
about media views, which handle a lot of this header business for you.
--
Our newest site for the community: CakePHP Video Tutorials
http://tv.cakephp.org
Check out the new CakePHP Questions site http://ask.cakephp.org and help others
with their CakePHP related questions.
To unsubscribe from this group, send email to
[email protected] For more options, visit this group at
http://groups.google.com/group/cake-php