Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR PHP

Laravel image handling

<?php

namespace AppTraits;

use IlluminateSupportStr;
use IlluminateHttpUploadedFile;
use IlluminateSupportFacadesStorage;

trait Upload
{
    public function UploadFile(UploadedFile $file, $folder = null, $disk = 'public', $filename = null)
    {
        $FileName = !is_null($filename) ? $filename : Str::random(10);
        return $file->storeAs(
            $folder,
            $FileName . "." . $file->getClientOriginalExtension(),
            $disk
        );
    }

    public function deleteFile($path, $disk = 'public')
    {
        Storage::disk($disk)->delete($path);
    }
}
Source by www.iankumu.com #
 
PREVIOUS NEXT
Tagged: #Laravel #image #handling
ADD COMMENT
Topic
Name
8+7 =