【问题标题】:Storage Directory full of copy image from public - Laravel存储目录充满了来自公共的副本图像 - Laravel
【发布时间】:2019-03-28 03:01:59
【问题描述】:

我打开 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);
        }
    }
}

【问题讨论】:

    标签: php laravel laravel-5


    【解决方案1】:

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

    【讨论】:

    • chmod 存储目录到 755?你的意思是每次下载图像时,laravel 都会将图像复制到存储目录?
    • 是的。为什么需要将图像复制到某个地方?
    • 等等。我有点失落。谁将图像放在存储目录中?我写的脚本还是 laravel?而且我不想为每个上传的图像创建一个副本。
    猜你喜欢
    • 2014-10-20
    • 1970-01-01
    • 2021-01-17
    • 1970-01-01
    • 2022-06-14
    • 2016-06-05
    • 2020-11-22
    • 2020-08-17
    • 1970-01-01
    相关资源
    最近更新 更多