Exemplo n.º 1
0
 public function save()
 {
     if ($this->_data) {
         unlink($this->saveDirectory . $this->_data);
     }
     if ($this->saveFilename) {
         $this->_data = $this->saveFilename;
     } else {
         if ($this->keepExtension) {
             $extension = explode('.', $this->uploadedFile->name);
             $extension = '.' . strtolower(array_pop($extension));
         } else {
             $extension = '.dat';
         }
         $this->_data = FileTools::createUniqueFilename($this->saveDirectory, $extension, 32, true) . $extension;
     }
     move_uploaded_file($this->uploadedFile->file, $this->saveDirectory . $this->_data);
 }
Exemplo n.º 2
0
 public function save()
 {
     if ($this->_image) {
         $this->onProcessImage($this->_image);
         if ($this->_data) {
             $this->saveFilename = $this->_data;
             if (!$this->valueContainsExtension) {
                 $this->saveFilename .= '.' . $this->saveFormat;
             }
         } else {
             if (!$this->saveFilename) {
                 $this->_data = FileTools::createUniqueFilename($this->saveDirectory, '.' . $this->saveFormat, 32, true);
                 if ($this->valueContainsExtension) {
                     $this->saveFilename = $this->_data = $this->_data . '.' . $this->saveFormat;
                 } else {
                     $this->saveFilename = $this->_data . '.' . $this->saveFormat;
                 }
             }
         }
         if ($this->resizeToWidth) {
             $image = ImageTools::resizeImage($this->_image, $this->resizeToWidth, $this->resizeToHeight, false, $this->resizeImageToolsScaleMode, $this->resizeImageToolsBackground);
         } else {
             $image = $this->_image;
         }
         if ($this->saveFormat == 'jpg') {
             imagejpeg($image, $this->saveDirectory . $this->saveFilename, $this->saveQuality);
         } else {
             if ($this->saveFormat == 'png') {
                 imagepng($image, $this->saveDirectory . $this->saveFilename);
             }
         }
         $this->onImageProcessed($this->_image);
         if ($image != $this->_image) {
             imagedestroy($this->_image);
         }
         imagedestroy($image);
     }
 }