2017 © Pedro Peláez
 

library laravel-file-uploader

A small helper class for easier file and image uploading in Laravel

image

voerro/laravel-file-uploader

A small helper class for easier file and image uploading in Laravel

  • Thursday, February 22, 2018
  • by AlexMordred
  • Repository
  • 1 Watchers
  • 0 Stars
  • 16 Installations
  • PHP
  • 0 Dependents
  • 0 Suggesters
  • 1 Forks
  • 0 Open issues
  • 7 Versions
  • 23 % Grown

The README.md

Laravel File Uploader

Packagist Packagist, (*1)

A very simple helper class that makes these tasks a walk in the park: - replacing an old/existing file with a new one - downsizing an image on upload - deleting a file from a storage - determining if a file is an image, (*2)

Installation

Via composer:, (*3)

composer require voerro/laravel-file-uploader

For Laravel Below 5.5

Add the FileUploaderServiceProvider to the providers array of your config/app.php configuration file:, (*4)

Voerro\FileUploader\FileUploaderServiceProvider::class,

Then add the Facade to the aliases array:, (*5)

'FileUploader' => Voerro\FileUploader\FileUploaderFacade::class,

Basic Usage

Import the FileUploader class like this:, (*6)

use Voerro\FileUploader\FileUploader;

Pass the uploaded file (an Illuminate\Http\UploadedFile) instance to the make method, then chain the upload method, which will return the path to the newly stored file., (*7)

$path = FileUploader::make($file)->upload();

Methods

Static methods

Initialization:, (*8)

::make(Illuminate\Http\UploadedFile $file)

Deleting a file (the method checks if the file exists to eliminate possible errors):, (*9)

::delete(string $filePath, string $storage = 'public')

Determine if a file is an image. Pass to the method an UploadedFile instance or a string with a path to the file:, (*10)

::isImage($file, $storage = 'public')

The following methods should be chained after the make method.

->upload(string $path = '', string $storage = 'public')

Upload file under a specified name:, (*11)

->uploadAs(string $filename, string $path = '', string $storage = 'public')

Replace an old file:, (*12)

->replace(string $oldFilePath, string $path = '', string $storage = 'public')

Replace an old file, store the new file under a specified name:, (*13)

->replaceAs(string $oldFilePath, string $newFilename, string $path = '', string $storage = 'public')

Downsize an image if it's bigger than the specified width and/or height (the aspect ratio will be saved). When called on a non-image file nothing would be happen, thus you don't need to manually check if the file is an image before deciding wether to call this method., (*14)

->downsize(integer $maxWidth, integer $maxHeight)

Crop and resize an image to fit the the specified dimensions (the same as ->fit() from Intervention Image), (*15)

->fit(integer $width, integer $height, boolean $dontUpsize = false)

Call this method before calling any of the above methods, for example:, (*16)

FileUploader::make($image)->downsize(200, 200)->replace('old_image_file.jpg');

License

This is open-sourced software licensed under the MIT license., (*17)

The Versions

22/02 2018

dev-master

9999999-dev

A small helper class for easier file and image uploading in Laravel

  Sources   Download

MIT

The Requires

 

The Development Requires

by Alexander Zavyalov

22/02 2018

v1.1.1

1.1.1.0

A small helper class for easier file and image uploading in Laravel

  Sources   Download

MIT

The Requires

 

The Development Requires

by Alexander Zavyalov

20/02 2018

v1.1.0

1.1.0.0

A small helper class for easier file and image uploading in Laravel

  Sources   Download

MIT

The Requires

 

The Development Requires

by Alexander Zavyalov

18/12 2017

v1.0.2

1.0.2.0

A small helper class for easier file and image uploading in Laravel

  Sources   Download

MIT

The Requires

 

The Development Requires

by Alexander Zavyalov

07/12 2017

v1.0.1

1.0.1.0

A small helper class for easier file and image uploading in Laravel

  Sources   Download

MIT

The Requires

 

The Development Requires

by Alexander Zavyalov

07/12 2017

v1.0

1.0.0.0

A small helper class for easier file and image uploading in Laravel

  Sources   Download

MIT

The Requires

 

The Development Requires

by Alexander Zavyalov

07/12 2017

1.0

1.0.0.0

A small helper class for easier file and image uploading in Laravel

  Sources   Download

MIT

The Requires

 

The Development Requires

by Alexander Zavyalov