Пример #1
0
 /**
  * uploads the selected file (the key is the name of the files control)
  * if successfull then it resizes the images, creating a thumbnail and a full size image
  * if then removes the source file
  *
  * @param string $key
  */
 public function upload($key, $subdir = null, $resize = true, $makeThumb = true, $thumbWidth = null, $fullWidth = null)
 {
     //try to upload the file
     if ($subdir !== null) {
         $path = self::IMAGE_PATH . '/' . $subdir;
     } else {
         $path = self::IMAGE_PATH;
     }
     $upload = parent::upload($key, $path);
     if ($upload) {
         if ($resize == true) {
             //make the full sized image
             if ($fullWidth == null) {
                 $fullWidth = self::FULL_WIDTH;
             }
             $this->fullPath = $this->resize($upload, $fullWidth, 'full_');
         } else {
             $this->fullPath = $upload;
         }
         if ($makeThumb) {
             //make the thumbnail
             if ($thumbWidth == null) {
                 $thumbWidth = self::THUMB_WIDTH;
             }
             $this->thumbPath = $this->resize($upload, $thumbWidth, 'thumb_');
         }
         if ($resize == true) {
             //remove the source file
             unlink($upload);
         }
     }
 }
Пример #2
0
 /**
  * uploads the selected file (the key is the name of the files control)
  * if successfull then it resizes the images, creating a thumbnail and a full size image
  * if then removes the source file
  *
  * @param string $key
  */
 public function uploadImage($key, $filename = false, $subdir = null, $resize = true, $makeThumb = true, $thumbWidth = null, $fullWidth = null)
 {
     //try to upload the file
     if ($subdir !== null) {
         $path = Digitalus_Toolbox_String::stripLeading('/', $subdir);
     } else {
         $path = self::IMAGE_PATH;
     }
     $upload = parent::upload($key, $path, $filename);
     if ($upload) {
         if ($resize == true) {
             //make the full sized image
             if ($fullWidth == null) {
                 $fullWidth = self::FULL_WIDTH;
             }
             $this->fullPath = $this->resize($upload, $fullWidth, 'full_');
         } else {
             $this->fullPath = $upload;
         }
         if ($makeThumb) {
             //make the thumbnail
             if ($thumbWidth == null) {
                 $thumbWidth = self::THUMB_WIDTH;
             }
             $this->thumbPath = $this->resize($upload, $thumbWidth, 'thumb_');
         }
         if ($resize == true) {
             //remove the source file
             unlink($upload);
         }
     }
 }