Esempio n. 1
0
 protected function removeFileFromStorage(File $file)
 {
     unlink("{$this->saveDirectory}/{$file->getPath()}");
     if (null !== $file->getThumbnailPath()) {
         unlink("{$this->saveDirectory}/{$file->getThumbnailPath()}");
     }
 }
 protected function showImage(Application $app, File $file, $mode)
 {
     if (null === $file->getThumbnailPath()) {
         return $app->redirect("/file/{$file->getId()}");
     }
     $ext = $file->getExtension();
     $ext = $ext === "jpg" ? "jpeg" : $ext;
     $imagecreate = "imagecreatefrom{$ext}";
     $image = "image{$ext}";
     switch ($mode) {
         case 'thumb':
             $im = $imagecreate("{$app['file.save_directory']}/{$file->getThumbnailPath()}");
             break;
         case 'original':
             $im = $imagecreate("{$app['file.save_directory']}/{$file->getPath()}");
             break;
     }
     return new Response($image($im), 200, array("Content-Type" => "{$file->getMimeType()}"));
 }