novius/laravel-easy-upload

This packages makes it way easier to deal with file uploads and src

Installs: 2 361

Dependents: 0

Suggesters: 0

Security: 0

Stars: 1

Watchers: 3

Forks: 0

Open Issues: 0

Language:HTML

1.2.0 2018-11-06 13:41 UTC

This package is not auto-updated.

Last update: 2021-10-09 01:42:39 UTC


README

Travis Packagist Release Licence

Treat file uploading as if it was just a text input

Installation

composer require novius/laravel-easy-upload

Then add this to config/app.php:

// in 'providers' => [ ... ]
Novius\EasyUpload\EasyUploadServiceProvider::class,

// in 'aliases' => [ ... ]
'Upload' => Novius\EasyUpload\Support\Renderer::class,

Use

In a view:

<form action="">
    <input name="title">
    <textarea name="description">
    {{ Upload::input(['name' => 'avatar_src']) }}
</form>

This will provide a <input type="hidden"> tag and a <input type="file"> tag. As soon as the user specify a file, it will be uploaded through ajax, and the resulting file src will be stored in the hidden inout value attribute.

Possible options are:

{{ Upload::input([
    'name' => 'avatar_src', // default: file_src
    'attribute' => 'data-name', // default: name
    'value' => 'upload/my-image-1234.jpg',
    'class' => 'any-class-you-want or-several-at-the-same-time'
]) }}

{{ Upload::link([ // show the uploaded file link
    'link_attributes' => 'class="my-link"',
    'accept' => '.pdf,.zip',
]) }}

{{ Upload::image([ // preview the uploaded picture
    'accept' => 'image/*',
]) }}