Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/jasekz/laradrop
File manager using Dropzone.js for Laravel 5.3 - 8.x - PHP
https://github.com/jasekz/laradrop
bootstrap composer-package demo dropzonejs javascript jquery laravel laravel-5-package laravel5 media-library packagist php
Last synced: 28 days ago
JSON representation
File manager using Dropzone.js for Laravel 5.3 - 8.x - PHP
- Host: GitHub
- URL: https://github.com/jasekz/laradrop
- Owner: jasekz
- License: mit
- Created: 2015-08-16T12:56:42.000Z (about 9 years ago)
- Default Branch: v1.1.2
- Last Pushed: 2021-12-15T14:57:37.000Z (almost 3 years ago)
- Last Synced: 2024-04-23T20:16:00.513Z (7 months ago)
- Topics: bootstrap, composer-package, demo, dropzonejs, javascript, jquery, laravel, laravel-5-package, laravel5, media-library, packagist, php
- Language: JavaScript
- Homepage:
- Size: 119 KB
- Stars: 72
- Watchers: 10
- Forks: 19
- Open Issues: 5
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
*This uses SoftDelete*
# Laradrop[![Software License][ico-license]](LICENSE.md)
This is a file manager using Dropzone.js for Laravel 5, 6, 7, 8. It provides basic functionality for managing, uploading,
and deleting files.## Quick Start
1) Follow the **Installation** instructions below.
Getting errors? Make sure you have a database set up (https://laravel.com/docs/database).
2) In a view (welcome.blade.php, for example), add:
```html
Laradrop Demo
jQuery(document).ready(function(){
jQuery('.laradrop').laradrop();
});
```
3) In your **.env** file, add:
```
LARADROP_DISK_PUBLIC_URL=/uploads
LARADROP_DISK=laradrop
```
4) In your **config/filesystems.php**, add to your `disks` array:
```
'laradrop' => [
'driver' => 'local',
'root' => public_path('uploads'), // will put files in 'public/upload' directory
],
```
That's it. If you have any issues or question, please feel free to open an issue.## Installation
NOTE: If you haven't set up a database yet for your app, please do that first as per Laravel docs - http://laravel.com/docs/database.
Via composer
```
composer require jasekz/laradrop
```Then in your `config/app.php` add
```php
'Jasekz\Laradrop\LaradropServiceProvider'
```
to the `providers` array.Then run
php artisan vendor:publish
followed byphp artisan migrate
## Configuration (.env)
Laradrop uses Laravel's Filesystem mechanism (https://laravel.com/docs/filesystem) and by default will store your
files in the `storage/app` directory. If you would like to modify this behavior, along with other default settings, you can set your `.env` file variables:
```php# s3, local, or Rackspace. See 'Other Driver Prerequisites' at https://laravel.com/docs/filesystem. Defaults to 'local'
LARADROP_DISK=local# If your files need to be web accessible, set this param. S3, for example, would be 'https://s3.amazonaws.com/my-bucket'. Defaults to the web root (public).
LARADROP_DISK_PUBLIC_URL=/img# If a thumbnail can not be generated due to incompatible file or any other reason, what image do you want to use? Defaults to 'vendor/jasekz/laradrop/img/genericThumbs/no-thumb.png'
LARADROP_DEFAULT_THUMB=/img/no-thumb.png# Max file upload size in MB. Defaults to 10.
LARADROP_MAX_UPLOAD_SIZE=20# Max file size (in MB) for which thumbnail generation will be attempted. If your server has an issue processing thumbs, you can lower this value. Defaults to 10.
LARADROP_MAX_THUMBNAIL_SIZE=10# Defaults to 150px.
LARADROP_THUMB_WIDTH=150# Defaults to 150px.
LARADROP_THUMB_HEIGHT=150# Run laradrop routes through middlware. Defaults to none.
LARADROP_MIDDLEWARE=web
```
## Usage
This package requires Dropzone.js, jQuery, and jQuery UI. Include these somewhere in your template:
``` php```
By default, Laradrop is designed for Bootstrap, but it's not a requirement. Include Bootstrap and the Laradrop styles if you'd like to use it:
``` php```
Add the html code where you'd like to implement the file manager. Note, that by default, there is no middleware assigned to the Laradrop controller, however, it you assign middleware which contains csrf protection, you must include the `laradrop-csrf-token="{{ csrf_token() }}"` attribute.
``` html
```Finally, bind it using jQuery:
```javascriptjQuery(document).ready(function(){
// Simplest:
jQuery('.laradrop').laradrop();
// With custom params:
jQuery('.laradrop-custom').laradrop({
breadCrumbRootText: 'My Root', // optional
actionConfirmationText: 'Sure about that?', // optional
onInsertCallback: function (obj){ // optional
// if you need to bind the select button, implement here
alert('Thumb src: '+obj.src+'. File ID: '+obj.id+'. Please implement onInsertCallback().');
},
onErrorCallback: function(msg){ // optional
// if you need an error status indicator, implement here
alert('An error occured: '+msg);
},
onSuccessCallback: function(serverRes){ // optional
// if you need a success status indicator, implement here
}
});
});```
## Events
Laradrop currently fires two events:1. **Jasekz\Laradrop\Events\FileWasUploaded** - this is fired after a file has been uploaded and saved.
2. **Jasekz\Laradrop\Events\FileWasDeleted** - this is fired after a file is deleted.## Handlers (upload, delete, list, etc)
If you'd like to implement your own hanldlers (or extend the existing ones with your own controllers), you can do so. All you need to do, is to defined the routes to the appropriate handlers in the button attributes. This also allows you to easily have multiple handlers for different use cases, if so desired.
``` html
```
## File type validations
The default implementation of accept checks the file's mime type or extension against this list. This is a comma separated list of mime types or file extensions.Eg.: image/*,application/pdf,.psd
If the Dropzone is clickable this option will also be used as accept parameter on the hidden file input as well.
## License
The MIT License (MIT). Please see [License File](LICENSE.md) for more information.
[ico-license]: https://img.shields.io/badge/license-MIT-brightgreen.svg?style=flat-square