src/Services/FileUploader.php
public function handle(UploadedFile $file, $path = 'files')
    {
        $filesize = $file->getClientSize();
        $mimetype = $file->getClientMimeType();
        $extension = strtolower($file->getClientOriginalExtension());
        $fileName = Str::slug(pathinfo($file->getClientOriginalName(), PATHINFO_FILENAME));
        $filename = $fileName.'.'.$extension;
        list($width, $height) = getimagesize($file);

        $filecounter = 1;
        while (Storage::has($path.'/'.$filename)) {
            $filename = $fileName.'_'.$filecounter++.'.'.$extension;
        }
        $path = $file->storeAs($path, $filename);
        $type = Arr::get(config('file.types'), $extension, 'd');

        return compact('filesize', 'mimetype', 'extension', 'filename', 'width', 'height', 'path', 'type');
    }
public function handle(UploadedFile $file, $path = 'files')
    {
        $filesize = $file->getClientSize();
        $mimetype = $file->getClientMimeType();
        $extension = strtolower($file->getClientOriginalExtension());
        $fileName = Str::slug(pathinfo($file->getClientOriginalName(), PATHINFO_FILENAME));
        $filename = $fileName.'.'.$extension;
        list($width, $height) = getimagesize($file);

        $filecounter = 1;
        while (Storage::has($path.'/'.$filename)) {
            $filename = $fileName.'_'.$filecounter++.'.'.$extension;
        }
        $path = $file->storeAs($path, $filename);
        $type = Arr::get(config('file.types'), $extension, 'd');

        return compact('filesize', 'mimetype', 'extension', 'filename', 'width', 'height', 'path', 'type');
    }
public function handle ( UploadedFile $ file , $ path = 'files' ) { $ filesize = $ file -> getClientSize ( ) ; $ mimetype = $ file -> getClientMimeType ( ) ; $ extension = strtolower ( $ file -> getClientOriginalExtension ( ) ) ; $ fileName = Str :: slug ( pathinfo ( $ file -> getClientOriginalName ( ) , PATHINFO_FILENAME ) ) ; $ filename = $ fileName . '.' . $ extension ; list ( $ width , $ height ) = getimagesize ( $ file ) ; $ filecounter = 1 ; while ( Storage :: has ( $ path . '/' . $ filename ) ) { $ filename = $ fileName . '_' . $ filecounter ++ . '.' . $ extension ; } $ path = $ file -> storeAs ( $ path , $ filename ) ; $ type = Arr :: get ( config ( 'file.types' ) , $ extension , 'd' ) ; return compact ( 'filesize' , 'mimetype' , 'extension' , 'filename' , 'width' , 'height' , 'path' , 'type' ) ; }
Handle the file upload. Returns the array on success, or false
on failure.

@param \Symfony\Component\HttpFoundation\File\UploadedFile $file
@param string                                              $path where to upload file

@return array|bool
Handle the file upload . Returns the array on success or false on failure .