Hi Everyone,
So here is my issue.

I have gotten the phpThumb and SWFupload components working. They
upload, create thumbnails and using an ajax call will even post the
thumbnails back on the page. There is an issue though. When I went
back to only allow people logged in to upload pictures cake would drop
my sessions. I tried many different things. I even deleted everything
in the view, but my session still did not appear. Finally I decided to
restore everything and simply delete:

var $components = array('Thumb','SwfUpload');

Once this line was removed my sessions were working. However, at this
point nothing else was. The other interesting thing is that the
session would end with pages that didn't use either of these
components (but use the same controller).

Here are the important parts of my controller: (I tried using that
before filter thing, but its pointless because my session ends in the
component...,)

<?php
class GalleryPhotosController extends AppController
{
        var $name = 'GalleryPhotos';
        var $components = array('Thumb','SwfUpload');
        var $helpers = array('Form','Javascript');

        function beforeFilter() {

        if ($this->action == 'add'||$this->action == 'modify') {
            $this->Session->id($this->params['pass'][0]);
            $this->Session->start();
        }

        parent::beforeFilter();
    }

        function add($galleryCatId=0){
                if ($this->requestAction('/members/isLoggedIn/')){
                        $memberId 
=$this->requestAction('/gallery_categories/findMemberId/'.
$galleryCatId);
                        if ($memberId==$this->Session->read('Member.id')){
                                $this->set('galleryCatId',$galleryCatId);
                                $eventId 
=$this->requestAction('/gallery_categories/findEventId/'.
$galleryCatId);
                                $this->set('eventId',$eventId);
                                $this->set('error',false);
                        }
                        else {
                                $this->set('error',true);
                        }
                }
                else {
                        $this->set('error',true);
                }
        }

        function upload($galleryCatId,$sessionId,$overwrite=false){
                if (isset($this->params['form']['Filedata'])) {
            // upload the file
            // use these to configure the upload path, web path, and
overwrite settings if necessary
            $this->SwfUpload->uploadpath = 'fileupload'.DS.
$galleryCatId.DS;
            $this->SwfUpload->webpath = '/fileupload/'.
$galleryCatId.'/';
            $this->SwfUpload->overwrite = $overwrite;  //by default,
SwfUploadComponent does NOT overwrite files
            //
            if ($this->SwfUpload->upload()) {
                $this->data['GalleryPhoto']['gallery_category_id'] =
$galleryCatId;
                if (!($file = $this->GalleryPhoto->save($this->data))){
                    $this->Session->setFlash('Database save failed');
                } else {
                        $this->data['GalleryPhoto']['id'] = $this-
>GalleryPhoto->getLastInsertId();
                        $this->data['GalleryPhoto']['photo_caption'] = "";
                        $this->data['GalleryPhoto']['photo_filename'] =
$galleryCatId.DS.$this->SwfUpload->filename;
                        $this->GalleryPhoto->save($this->data);

                        if(!$this->Thumb->generateThumbnail($this->SwfUpload-
>uploadpath.$this->SwfUpload->filename,$this->SwfUpload-
>uploadpath.'tb_'.$this->SwfUpload->filename)){
                                        pr($this->Thumb->errors);
                                }
                }
            } else {
                $this->Session->setFlash($this->SwfUpload-
>errorMessage);
            }
        }
        }

}
?>

I could also add the components they actually may be useful. I am sure
most of you have them though. I didn't include the view because
completely deleting everything from it had no effect.

My security settings are medium, I have turned off checkUserAgent.
Thanks!!!!

--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups 
"CakePHP" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to 
[email protected]
For more options, visit this group at 
http://groups.google.com/group/cake-php?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to