【发布时间】: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);
}
}
}
【问题讨论】: