mobilemaster/laravel-file-input

Laravel 5/File Input - Handle large file uploads

1.4 2018-03-07 12:38 UTC

This package is not auto-updated.

Last update: 2024-05-06 05:12:51 UTC


README

Laravel bootstrap file input support.

Handeling chunked uploads.

1. Installation

  1. Require the package using composer:

    composer require mobilemaster/laravel-file-input
    
  2. Add the service provider to the providers in config/app.php:

    Laravel 5.5 uses Package Auto-Discovery, so doesn't require you to manually add the ServiceProvider

    MobileMaster\LaravelFileInput\ServiceProvider::class,
  3. Publish the public assets:

    php artisan vendor:publish --provider="MobileMaster\LaravelFileInput\ServiceProvider" --tag=assets
    
  4. Configuration

    First, publish the configuration file:

    php artisan vendor:publish --provider="MobileMaster\LaravelFileInput\ServiceProvider" --tag=config
    

    Now, edit config/fileinput.php to configure the lang.

2. Updating

  1. To update this package, first update the composer package:

    composer update mobilemaster/laravel-file-input
    
  2. Then, publish the public assets with the --force flag to overwrite existing files

    php artisan vendor:publish --provider="MobileMaster\LaravelFileInput\ServiceProvider" --tag=assets --force
    

3. Sending files

There are 2 ways to send files with this plugin.

1. Simple File Input builder

To use the builder for creating send form you can use this function:

echo FileInput::make([
    'uploadUrl' => 'upload',
]);

Note: The options given to the make function are found on in the file input documentation.

2. Extended File Input builder

echo FileInput::init([
    'uploadUrl' => 'upload',
])->withSuffix('current')->createHtml();

4. Receiving files

Use this controller to receive a file on the url /upload.

public function imageFileUpload(Request $request)
{
    $path = $request->file('file_data')->store('uploads');
    return [
        'error' => NULL,
        'path' => $path,
    ];
}