laravel-easy-upload maintained by novius
Easy Upload
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/*',
]) }}