Nette\Http\FileUpload::getTemporaryFile PHP Method

getTemporaryFile() public method

Returns the path to an uploaded file.
public getTemporaryFile ( ) : string
return string
    public function getTemporaryFile()
    {
        return $this->tmpName;
    }

Usage Example

Example #1
0
 /**
  * @param Nette\Http\FileUpload $file
  * @param string $path
  * @param array $enabledExt
  * @return bool
  */
 protected function saveFile($file, $path, $enabledExt = array('jpg', 'jpeg'))
 {
     if ($file->error) {
         return false;
     }
     $filename = $file->getName();
     if (!in_array(self::getExtensionByName($filename), $enabledExt)) {
         return false;
     }
     try {
         $src = imagecreatefromjpeg($file->getTemporaryFile());
         list($width, $height) = getimagesize($file->getTemporaryFile());
         $aspectRatio = $width / $height;
         if ($aspectRatio > 1) {
             $targetWidth = self::MAX_DIMENSION;
             $targetHeight = round(self::MAX_DIMENSION / $aspectRatio);
         } else {
             $targetWidth = round(self::MAX_DIMENSION * $aspectRatio);
             $targetHeight = self::MAX_DIMENSION;
         }
         $bigThumbnail = imagecreatetruecolor($targetWidth, $targetHeight);
         imagecopyresampled($bigThumbnail, $src, 0, 0, 0, 0, $targetWidth, $targetHeight, $width, $height);
         imagejpeg($bigThumbnail, self::SAVE_DIR . $path, 75);
     } catch (\Exception $e) {
         return false;
     }
     return true;
 }
All Usage Examples Of Nette\Http\FileUpload::getTemporaryFile