dimanche 29 mai 2016

Store uploaded images with Laravel 5

I'm trying to upload, convert and store an image in Laravel using Image Magick.

Inside App\Http\Controllers\ArticleController:

$image = $this->storeMainImage($request->file('thumbnail'));

The function:

private function storeMainImage($file) {
  $folder = 'uploads/images/'; <--- ?????
  $code = uniqid();
  $thumb_code = $folder . 'thumb_' . $code . '.jpg';
  $image_code = $folder . $code . '.jpg';
  if(@is_array(getimagesize($file))){
    exec('convert '.$file.'  -thumbnail 225x225^ -gravity center -extent 225x225  -compress JPEG -quality 70  -background fill white  -layers flatten  -strip  -unsharp 0.5x0.5+0.5+0.008  '.$thumb_code);
    exec('convert '.$file.'  -compress JPEG -quality 70  -background fill white  -layers flatten  -strip  -unsharp 0.5x0.5+0.5+0.008  '.$image_code);
    return $image_code;
  } else {
    return false;
  }
}

I don't get any errors with this, but I have no idea if it's actually uploading the file and where abouts it's storing it.



from Newest questions tagged laravel-5 - Stack Overflow http://ift.tt/25qpXcM
via IFTTT

Aucun commentaire:

Enregistrer un commentaire