存储目录中充满了来自公共的复制映像-Laravel

时间:2018-10-23 19:19:26

标签: php laravel laravel-5

已经有一段时间了,因为我打开了Laravel目录,发现storage / app文件夹中有很多图像(可能是从公共目录复制的),但是我不记得曾经将上传的图像放在那里。 Laravel是否自动将它们放在那里?如何关闭它?。这会导致磁盘已满。

这是我的上传脚本...

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

1 个答案:

答案 0 :(得分:0)

Laravel不会在您的目录中自动生成图像。我建议您在下载图片时输入验证码,并在目录755上设置权限

相关问题