Skip to content

nabilanam/simpleupload

Repository files navigation

SimpleUpload

Latest Stable Version Total Downloads Latest Unstable Version License composer.lock available

Dead simple Laravel file uploader.

Installation

Via Composer:

$ composer require nabilanam/simpleupload

You can publish the config file:

php artisan vendor:publish --provider="NabilAnam\SimpleUpload\SimpleUploadServiceProvider"

Usage

// somewhere in your controller

use NabilAnam\SimpleUpload\SimpleUpload;

public function update(Request $request, YourModel $model)
{
    $model->image = (new SimpleUpload)
        ->file($request->image) // store normal request file
        ->fileBase64($request->image) // store file from base64 image data uri
        ->dirName('images') // directory to store the file into
        ->resizeImage(600, 100) // resize with intervention
        ->keepAspectRatio() // best fit aspect ratio by intervention
        ->intervention(function ($image) { // need more?
            return $image;
        })
        ->skipDay() // removes day directory from path
        ->skipMonth() // removes month directory from path
        ->skipYear() // removes year directory from path
        ->skipDirectory() // removes day, month, year directory from path
        ->deleteIfExists($model->image) // deletes file with given path
        ->save(); // processs && return final file path

    $model->save();

    return back();
}

// somewhere in your blade file

<img src="{{ asset($model->image) }}" alt="image">

Change log

Please see the changelog for more information on what has changed recently.

Contributing

Pull requests are welcome!

Security

If you discover any security related issues, please email nabil_code@outlook.com instead of using the issue tracker.

Credits

License

MIT. Please see the license file for more information.

About

Dead simple Laravel file uploader

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages