简体   繁体   中英

Storage Directory full of copy image from public - Laravel

It's been a while since I open my Laravel directory and I found there are many images in storage/app folder (probably copied from the public directory) but I don't remember ever putting uploaded images there. did Laravel put them there automatically? How do I turn it off? It causes my disk to be full.

Here's my upload script...

<?php

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);
        }
    }
}

Laravel does not automatically generate images in your directory. I would advise you to put a captcha on downloading images, as well as set permissions on the directory 755

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM