I pass the session id to the upload script, the auth session as never
timed out on me while using it. Each upload sends the session id, it
is in the javascript.
-a

On May 3, 1:03 pm, Sam Sherlock <sam.sherl...@gmail.com> wrote:
> Hi Miles,
>
> have you tried to use your uploader with uploadify or swfupload?
>
> @abocanegra
>
> I mean that the user is logged in through auth.  I think that the follow up
> requests that uploadify uses to check success of queued items are passed
> with out Session ID (appened to query string) and so the auth session is
> terminated by the time the uploads are complete
>
> - S
>
> On 3 May 2010 18:04, Miles J <mileswjohn...@gmail.com> wrote:
>
> > It would be better to actually use an uploader that was built for
> > Cake.
>
> >http://github.com/milesj/uploader
>
> > On May 3, 5:28 am, abocanegra <aaronbocane...@gmail.com> wrote:
> > > Could you clarify what you mean by admin routing. I have it working
> > > solidly in my multi-user admin system. I have chosen to save the data
> > > outside of the cakePHP admin section for this specific project. I have
> > > everything routing based on roles. Sorry i am unclear on some
> > > terminology, if you can clarify the question,  can answer.
>
> > > Below is the image.php component code I have altered for my own
> > > purposes including the ability to work with single or multi-image
> > > upload (uploadify)
>
> > > /////////////////////////////////////////////////// image.php
>
> > > <?php
> > > /*
> > >  File: /app/controllers/components/image.php
> > > */
> > > class ImageComponent extends Object
> > > {
> > >  /*
> > >  * Uploads an image and its thumbnail into $folderName/big and
> > > $folderName/small respectivley.
> > >  *  Also uploads a zoom cropped image into $folderName/home. You could
> > > easily modify it to suit your needs!
>
> > >  *  Directions:
> > >  * In view where you upload the image, make sure your form creation is
> > > similar to the following
> > >  * <?= $form->create('FurnitureSet',array('type' => 'file')); ?>
>
> > >  * In view where you upload the image, make sure that you have a file
> > > input similar to the following
> > >  * <?= $form->file('Image/name1'); ?>
>
> > >  * In the controller, add the component to your components array
> > >  * var $components = array("Image");
>
> > >  * In your controller action (the parameters are expained below)
> > >  * $image_path =
> > $this->Image->upload_image_and_thumbnail($this->data,"name1", 573,380,80,80,
> > "sets");
>
> > >  * this returns the file name of the result image.  You can  store
> > > this file name in the database
> > >  *
> > >  * Note that your image will be stored in 3 locations:
> > >  * Image: /webroot/img/$folderName/big/$image_path
> > >  * Thumbnail:  /webroot/img/$folderName/small/$image_path
> > >  * Homepage:  /webroot/img/$folderName/home/$image_path
> > >  *
> > >  * You could easily add more locations or remove locations you don't
> > > need
>
> > >  * Finally in the view where you want to see the images
> > >  * <?= $html->image('sets/big/'.$furnitureSet['FurnitureSet']
> > > ['image_path']);
> > >  *  where "sets" is the folder name we saved our pictures in, and
> > > $furnitureSet['FurnitureSet']['image_path'] is the file name we stored
> > > in the database
>
> > >  * Parameters:
> > >  * $data: CakePHP data array from the form
> > >  * $datakey: key in the $data array. If you used <?=
> > $form->file('Image/name1'); ?> in your view, then $datakey = name1
>
> > >  * $maxw: the maximum width that you want your picture to be resized
> > > to
> > >  * $maxh: the maximum width that you want your picture to be resized
> > > to
> > >  * $thumbscalew: the maximum width hat you want your thumbnail to be
> > > resized to
> > >  * $thumbscaleh: the maximum height that you want your thumbnail to be
> > > resized to
> > >  * $folderName: the name of the parent folder of the images. The
> > > images will be stored to /webroot/img/$folderName/big/ and  /webroot/
> > > img/$folderName/small/
> > >  */
> > >  function upload_image_and_thumbnail($data, $datakey, $maxw, $maxh,
> > > $thumbscalew, $thumbscaleh, $folderName, $multi) {
> > >         if($multi == false){
> > >         $dName = $data['Image'][$datakey]['name'];
> > >         $dTempName = $data['Image'][$datakey]['tmp_name'];
> > >         }else if($multi == true){
> > >         $dName = $datakey;
> > >         $dTempName = $data;
> > >         }
> > >         if(strlen($dName)>4){
> > >         $error = 0;
> > >          $homedir = "../../../uploads";
> > >          if(!is_dir($homedir)){mkdir($homedir, 0777, true);}
> > >      $tempuploaddir = $homedir . "/temp"; // the /temp/ directory,
> > > should delete the image after we upload
> > >          if(!is_dir($tempuploaddir)){mkdir($tempuploaddir, 0777, true);}
> > >      $homeuploaddir = $homedir."/images/".$folderName."/home"; // the /
> > > home/ directory
> > >          if(!is_dir($homeuploaddir)){ mkdir($homeuploaddir , 0777,
> > > true);}  // octal; correct value of mode
> > >          $biguploaddir = $homedir . "/images/".$folderName."/big"; // the
> > /
> > > big/ directory
> > >          if(!is_dir($biguploaddir)){mkdir($biguploaddir , 0777, true);}
> >  //
> > > octal; correct value of mode
> > >      $smalluploaddir = $homedir . "/images/".$folderName."/small"; //
> > > the /small/ directory for thumbnails
> > >          if(!is_dir($smalluploaddir)){mkdir($smalluploaddir, 0777,
> > > true);}  // octal; correct value of mode
>
> > >      // Make sure the required directories exist, and create them if
> > > necessary
> > >      if(!is_dir($tempuploaddir)) mkdir($tempuploaddir,true);
> > >      if(!is_dir($homeuploaddir)) mkdir($homeuploaddir,true);
> > >      if(!is_dir($biguploaddir)) mkdir($biguploaddir,true);
> > >      if(!is_dir($smalluploaddir)) mkdir($smalluploaddir,true);
>
> > >         $filetype = $this->getFileExtension($dName);
> > >         $filetype = strtolower($filetype);
>
> > >      if (($filetype != "jpeg")  && ($filetype != "jpg") && ($filetype !
> > > = "JPG") && ($filetype != "gif") && ($filetype != "png"))
> > >      {
> > >       // verify the extension
> > >       return;
> > >      }
> > >      else
> > >      {
> > >       // Get the image size
> > >       $imgsize = GetImageSize($dTempName);
> > >         }
>
> > >      // Generate a unique name for the image (from the timestamp)
> > >      $id_unic = str_replace(".", "", strtotime ("now"));
> > >      $filename = $id_unic;
>
> > >      settype($filename,"string");
> > >      $filename.= ".";
> > >      $filename.=$filetype;
> > >      $tempfile = $tempuploaddir . "/$filename";
> > >          //chmod($tempfile, 0777);
> > >      $homefile = $homeuploaddir . "/$filename";
> > >          //chmod($homefile, 0777);
> > >      $resizedfile = $biguploaddir . "/$filename";
> > >          //chmod($resizedfile, 0777);
> > >      $croppedfile = $smalluploaddir . "/$filename";
> > >          //chmod($croppedfile, 0777);
>
> > >             if (is_uploaded_file($dTempName)){
> > >       // Copy the image into the temporary directory
> > >                                   if (!copy($dTempName,"$tempfile")){
> > >                             print "Error Uploading File!.";
> > >                             exit();
> > >                         }
> > >       else {
> > >        /*
> > >         * Generate the home page version of the image center cropped
> > >         */
> > >        $this->resizeImage('resizeCrop', $tempuploaddir, $filename,
> > > $homeuploaddir, $filename, 600, 400, 90);
> > >        /*
> > >         * Generate the big version of the image with max of $imgscale
> > > in either directions
> > >         */
> > >        $this->resizeImage('resize', $tempuploaddir, $filename,
> > > $biguploaddir, $filename, $maxw, $maxh, 90);
>
> > >        /*
> > >         * Generate the small thumbnail version of the image with scale
> > > of $thumbscalew and $thumbscaleh
> > >         */
> > >        $this->resizeImage('resizeCrop', $tempuploaddir, $filename,
> > > $smalluploaddir, $filename, $thumbscalew, $thumbscaleh, 85);
>
> > >        // Delete the temporary image
> > >        unlink($tempfile);
> > >       }
> > >                     }
>
> > >                      // Image uploaded, return the file name
> > >       return $filename;
> > >   }
> > >  }
>
> > >  /*
> > >  * Deletes the image and its associated thumbnail
> > >  * Example in controller action:
> > $this->Image->delete_image("1210632285.jpg","sets");
>
> > >  *
> > >  * Parameters:
> > >  * $filename: The file name of the image
> > >  * $folderName: the name of the parent folder of the images. The
> > > images will be stored to /webroot/img/$folderName/big/ and  /webroot/
> > > img/$folderName/small/
> > >  */
> > >          function remove_image($filename, $folderName)
> > >          {
> > >          $homedir = "../../../uploads";
> > >      $homeuploaddir = $homedir."/images/".$folderName."/home"; // the /
> > > home/ directory
> > >          $biguploaddir = $homedir . "/images/".$folderName."/big"; // the
> > /
> > > big/ directory
> > >      $smalluploaddir = $homedir . "/images/".$folderName."/small"; //
> > > the /small/ directory for thumbnails
>
> > >                  unlink($homeuploaddir . '/' . $filename);
> > >                  unlink($biguploaddir . '/' . $filename);
> > >                  unlink($smalluploaddir . '/' . $filename);
> > >          }
>
> > >     function getFileExtension($str) {
>
> > >         $i = strrpos($str,".");
> > >         if (!$i) { return ""; }
> > >         $l = strlen($str) - $i;
> > >         $ext = substr($str,$i+1,$l);
> > >         return $ext;
> > >     }
>
> > >  /*
> > >   * @param $cType - the conversion type: resize (default), resizeCrop
> > > (square), crop (from center)
> > >   * @param $id - image filename
> > >   * @param $imgFolder  - the folder where the image is
> > >   * @param $newName - include extension (if desired)
> > >   * @param $newWidth - the  max width or crop width
> > >   * @param $newHeight - the max height or crop height
> > >   * @param $quality - the quality of the image
> > >   * @param $bgcolor - this was from a previous option that was
> > > removed, but required for backward compatibility
> > >   */
> > >  function resizeImage($cType = 'resize', $srcfolder, $srcname,
>
> ...
>
> read more »

Check out the new CakePHP Questions site http://cakeqs.org and help others with 
their CakePHP related questions.

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

Reply via email to