diff --git a/app/Api/ImageResize.php b/app/Api/ImageResize.php index 753809e..9d3ef47 100755 --- a/app/Api/ImageResize.php +++ b/app/Api/ImageResize.php @@ -17,8 +17,8 @@ class ImageResize $folder = Carbon::now()->format('Y/m/d'); $path = "uploads/{$type}/thumbs/{$folder}"; - if (!file_exists($path)) { - mkdir($path, 0755, true); + if (!file_exists(public_path($path))) { + mkdir(public_path($path), 0775, true); } return $path; @@ -49,11 +49,15 @@ class ImageResize $img->save("{$path_thumb}", 100); Storage::disk('s3')->put($path_thumb, file_get_contents($path_thumb)); } else { - $img = Imagee::make(public_path($path)); + // source can be in storage/app/public (from ->store('temp','public')) or public/ + $srcPath = file_exists(public_path($path)) + ? public_path($path) + : storage_path('app/public/' . $path); + $img = Imagee::make($srcPath); $img->resize($size, null, function ($constraint) { $constraint->aspectRatio(); }); - $img->save(public_path() . "/{$path_thumb}", 100); + $img->save(public_path($path_thumb), 100); } return $path_thumb; } diff --git a/app/Http/Requests/Dashboard/Product/Update.php b/app/Http/Requests/Dashboard/Product/Update.php index 4bce7ee..62ab432 100755 --- a/app/Http/Requests/Dashboard/Product/Update.php +++ b/app/Http/Requests/Dashboard/Product/Update.php @@ -68,7 +68,8 @@ class Update extends FormRequest Storage::disk('s3')->delete($product->poster); } else { // delete old file - unlink($product->poster); + $oldPath = public_path($product->poster); + if (is_file($oldPath)) unlink($oldPath); } $folder = "uploads/posters/" . Carbon::now()->format('Y/m/d'); diff --git a/storage/.DS_Store b/storage/.DS_Store old mode 100644 new mode 100755