Can you elaborate on base64 encode comment? I thought the binary data is 
already needed to be encoded. do you have examples of doing this?

thanks in advance.
-bc

header comment is not needed as cake MediaView does that for you (as you 
said). I had this in and out while trying different things. It's not there 
in the final.

On Tuesday, March 6, 2012 3:40:11 PM UTC-5, cricket wrote:
>
> If you're going to use a Base64 data URI you'll need to encode the output.
>
> Are you trying to do this because the images are above webroot?
>
> Also, there's a problem with this line:
>
> header('Content-type: $type');
>
> Where does $type come from? Anyway, I think MediaView handles that header.
>
> On Tue, Mar 6, 2012 at 9:56 AM, Blues Clues <[email protected]> wrote:
> > Hi
> > I am trying to display image retrieved using MediaView based
> > Controller.
> >
> > My controller looks like this:
> >
> > CONTROLLER:
> >
> >    function getImg(){
> >          $this->autoLayout = false;
> >          if($this->RequestHandler->isAjax()){
> >             Configure::write('debug', 0);
> >          }
> >                $this->view = 'Media';
> >                header('Content-type: $type');
> >                $params = array('id' => '175209_20.png',
> >                                                'name' => 'user_img_name',
> >                                                'download' => false,
> >                                                'extension' => 'png',  // 
> must be lower case
> >                                                'path' => APP.WEBROOT_DIR 
> . DS . 'files\upload' . DS
> >                                                );
> >                $this->set($params);
> >        }
> >
> > I hardcoded image name here just to see if this works atleast.
> >
> > VIEW:
> >
> > <script>
> > $.ajax({
> >                                                         url: 
> baseAction+'images/getImg',
> >                                                         data: 'id='+id,
> >                                                         success: 
> function(msg){
> >                                                         
> $('#preview-img').html('<img src="data:image/png;base64,' +
> > msg + '" ></img>');
> >                                                         }
> >                                                         
> }).error(function(){
> >                                                         alert('ajax 
> error!');                                           });
> >
> > </script>
> >
> >
> > the image is displayed as:
> >
> > <img src="�PNG���������������������������������
> >
> > [COLOR=red][B]Can you tell how to use this MediaView in a controller
> > and display images?
> > [/B][/COLOR]
> >
> > I am very close I think but this is killing me.
> >
> > Thanks
> > -BC
> >
> > --
> > 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
>
>

-- 
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

Reply via email to