Make thumbnail fix

This commit is contained in:
root
2021-09-21 21:06:36 +02:00
parent 6ea0c96557
commit 493c10eb45
2 changed files with 7 additions and 15 deletions

View File

@@ -4,6 +4,7 @@ namespace App\Http\Controllers;
use Illuminate\Http\Request;
use Carbon\Carbon;
use Intervention\Image\ImageManagerStatic as Image;
class Upload extends Controller
{
@@ -40,14 +41,16 @@ class Upload extends Controller
$location = config('app.image.dir');
$backupdir = Carbon::now()->format('Y/m/d');
$backupdir = sprintf($location.'/backup/%s',$backupdir);
$backupdir = sprintf($location.'/backup/%s',$backupdir);
$thumbdir = sprintf('%s/%s', config('app.image.thumb_dir'), Carbon::now()->format('Y/m/d'));
$bckfile = Carbon::now()->format('Hi');
$bckfile = sprintf('%s.jpg',$bckfile);
// Upload file
$file->move($backupdir,$bckfile);
\File::copy($backupdir."/".$bckfile,$location."/".$filename);
$image = Image::make($backupdir."/".$bckfile)->resize(160, 120);
$image->save( config('app.image.thumb_dir').'/'.$bckfile);
$image = Image::make($backupdir."/".$bckfile)->resize(160, 120);
\File::makeDirectory($thumbdir, $mode = 0770, true, true);
$image->save( $thumbdir.'/'.$bckfile);
echo 'Upload Successful.';
}else{
echo 'File too large. File must be less than 2MB.';