dosarkz/laravel-uploader

There is no license information available for the latest version (0.2.4) of this package.

Uploading Class for laravel 5

0.2.4 2017-12-22 06:47 UTC

This package is auto-updated.

Last update: 2024-03-29 03:03:52 UTC


README

Laravel 5 image and file uploader with resizer http://image.intervention.io/

Install

composer require dosarkz/laravel-uploader

Add to config/app.php

Provider

Dosarkz\LaravelUploader\Provider\LaravelUploaderServiceProvider::class

Alias

'Uploader' => Dosarkz\LaravelUploader\Facade\LaravelUploaderFacade::class
  

Sample image upload

Uploader::image(uploaded_file, destination, resize, imageWidth, imageHeight, thumbWidth, thumbHeight)
  • @uploaded_file - instance of UploadedFile
  • @destination - the path to the image, 'images/articles', string
  • @resize - A parameter that determines to use compression or not. In the case of using need to fill one of the parameters the resolution of the image, true or false, boolean
  • @imageWidth, @imageHeight - the parameters of the image in pixels, 100, numeric
  • @thumbWidth, @thumbHeight - the parameters of the thumbnail in pixels, 100, numeric
  use Uploader;
  
  $image_uploader  = Uploader::image($request->file('avatar'));
  $image = Image::create([
      'name' => $image_uploader->getFileName(),
      'thumb' => $image_uploader->getThumb(),
      'path' => $image_uploader->getDestination(),
  ]);

Sample file upload

Uploader::file(uploaded_file, destination)
  • @uploaded_file - instance of UploadedFile
  • @destination - the path to the image, 'images/articles', string
use Uploader;
  
 $image_uploader  = Uploader::file($request->file('file'));

  $file = File::create([
      'name' => $image_uploader->getFileName(),
      'path' => $image_uploader->getDestination(),
      'user_id' => auth()->user()->id
  ]);