Little changes to make thumb

This commit is contained in:
2021-09-21 20:39:55 +02:00
parent 714327b236
commit 9fa0c888ca
10 changed files with 193 additions and 6 deletions

View File

@@ -0,0 +1,42 @@
<?php
namespace App\Console\Commands;
use Illuminate\Console\Command;
class Thumbnail extends Command
{
/**
* The name and signature of the console command.
*
* @var string
*/
protected $signature = 'thumbnail:make';
/**
* The console command description.
*
* @var string
*/
protected $description = 'Make thumbnails of all image files';
/**
* Create a new command instance.
*
* @return void
*/
public function __construct()
{
parent::__construct();
}
/**
* Execute the console command.
*
* @return mixed
*/
public function handle()
{
}
}

View File

@@ -37,15 +37,17 @@ class Upload extends Controller
if($fileSize <= $maxFileSize){
// File upload location
$location = 'upload/images';
$location = config('app.image.dir');
$backupdir = Carbon::now()->format('Y/m/d');
$backupdir = sprintf('upload/images/backup/%s',$backupdir);
$backupdir = sprintf($location.'/backup/%s',$backupdir);
$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);
echo 'Upload Successful.';
}else{
echo 'File too large. File must be less than 2MB.';