mardi 23 octobre 2018

storage directory full of copy image from public - laravel

It's been a while since I open my laravel directory again and I found there are many images in storage/app folder (probably copied from public directory) but I dont remember I ever put uploaded image there. did laravel put them there automatically? and how to turn it off? because it cause my disk full.

here is my upload script.

  protected function uploadPhoto($photo, $photoName)
{
    $attachment = $photo;
    $photoName =  $photoName.'.jpg';
    $storePhoto = ($attachment) ? $attachment->storeAs('gallery', $photoName) : null;

    if ($storePhoto) {
        $path = public_path('images/' . $storePhoto);
        $path_thumb = public_path('images/' . str_replace('gallery', 'gallery/thumbnails/', $storePhoto));

        $img = Image::make($attachment->getRealPath());
        $img->resize(1024, null, function ($constraint) {
            $constraint->aspectRatio();
        });

        if ($img->save($path, 85)) {
            Image::make($path)->resize(300, null, function ($constraint) {
                $constraint->aspectRatio();
            })->Save($path_thumb, 60);
        }
    }
}



via Chebli Mohamed

Aucun commentaire:

Enregistrer un commentaire