All Projects → codingo-me → dropzoner

codingo-me / dropzoner

Licence: MIT license
Laravel package for image upload using DropzoneJS

Programming Languages

PHP
23972 projects - #3 most used programming language
HTML
75241 projects
javascript
184084 projects - #8 most used programming language

Projects that are alternatives of or similar to dropzoner

laravel-username-generator
Automatically generate usernames for Laravel User Model
Stars: ✭ 37 (-19.57%)
Mutual labels:  package, laravel-package
Laravel Google Translate
This package makes using the Google Translate API in your laravel app a breeze with minimum to no configuration, clean syntax and a consistent package API.
Stars: ✭ 97 (+110.87%)
Mutual labels:  package, laravel-package
Package Skeleton
📦 My base for PHP packages.
Stars: ✭ 6 (-86.96%)
Mutual labels:  package, laravel-package
Laravel Aws Sns
Laravel package for the AWS SNS Events
Stars: ✭ 24 (-47.83%)
Mutual labels:  package, laravel-package
Laravel Multilingual Routes
A package to handle multilingual routes in your Laravel application.
Stars: ✭ 241 (+423.91%)
Mutual labels:  package, laravel-package
video-downloader
Video Downloader for Facebook.
Stars: ✭ 63 (+36.96%)
Mutual labels:  package, laravel-package
Laravel Pdf
A Simple package for easily generating PDF documents from HTML. This package is specially for laravel but you can use this without laravel.
Stars: ✭ 79 (+71.74%)
Mutual labels:  package, laravel-package
yii2-dropzone
This extension provides the Dropzone integration for the Yii2 framework.
Stars: ✭ 11 (-76.09%)
Mutual labels:  dropzone, dropzonejs
Blogetc
Easily add a full Laravel blog (with built in admin panel and public views) to your laravel project with this simple package.
Stars: ✭ 198 (+330.43%)
Mutual labels:  package, laravel-package
Laravel Short Url
A Laravel package to shorten urls
Stars: ✭ 127 (+176.09%)
Mutual labels:  package, laravel-package
Laravel Natural Language
This package makes using the Google Natural API in your laravel app a breeze with minimum to no configuration, clean syntax and a consistent package API.
Stars: ✭ 119 (+158.7%)
Mutual labels:  package, laravel-package
response
Response HTTP package for Simfony, Laravel, Lumen and PHP 7 with standard REST API
Stars: ✭ 14 (-69.57%)
Mutual labels:  package, laravel-package
Laravel Gitscrum
GitScrum is a Project Management Tool, developed to help entrepreneurs, freelancers, managers, and teams Skyrocket their Productivity with the Agile methodology and Gamification.
Stars: ✭ 2,686 (+5739.13%)
Mutual labels:  package, laravel-package
laravel-repoman
Set a payment deadline for the customer
Stars: ✭ 14 (-69.57%)
Mutual labels:  package, laravel-package
cloup
Library to build command line interfaces (CLIs) based on Click. Cloup = Click + option groups, constraints, command aliases, command sections, help themes, "did you mean ...?" suggestions ...
Stars: ✭ 44 (-4.35%)
Mutual labels:  package
artisan-cloudflare
Laravel artisan commands for CloudFlare
Stars: ✭ 67 (+45.65%)
Mutual labels:  laravel-package
secure compare
A secure compare for Elixir.
Stars: ✭ 17 (-63.04%)
Mutual labels:  package
atom-toolbar-almighty
Atom editor's missing toolbar
Stars: ✭ 21 (-54.35%)
Mutual labels:  package
laravel-livewire-ui
Laravel Livewire UI, Auth, & CRUD starter kit.
Stars: ✭ 92 (+100%)
Mutual labels:  package
Laravel-Unsplash-Wrapper
A Laravel wrapper for Unsplash API's.
Stars: ✭ 21 (-54.35%)
Mutual labels:  laravel-package

Dropzoner - Laravel package for image upload using DropzoneJS

Software License Total Downloads

This is the simplest Laravel package for image uploads using DropzoneJS.

You pull it via composer, set service provider and include it in your views with @include('dropzoner::dropzone'). After this you need to set JS and CSS files in header and footer. Dropzone will take full width of parent container, and will throw events on image upload and image delete actions. Using event listeners you can hook this package with the rest of your application.

Package uses Image Intervention library for saving images. It has its own filename sanitizer and method for creating unique filenames inside upload directory.

Guide

Require package in your Laravel project with:

composer require codingo-me/dropzoner

Now modify app.php config file and add Dropzoner Service Provider.

        Codingo\Dropzoner\DropzonerServiceProvider::class

After setting service provider you need to publish Dropzoners configuration file and assets:

php artisan vendor:publish

When you publish these files, you will be able to modify Dropzoner configuration. There you'll find validator array and validator-messages array.

You also need to add upload path into .env file using key DROPZONER_UPLOAD_PATH. This directory should be write-able by web server, and it needs to end with trailing slash.

Namespace

Package uses Codingo\Dropzoner namespace.

Assets

In head section of your page add DropzoneJS stylesheet file.

<link rel="stylesheet" href="<?php echo asset('vendor/dropzoner/dropzone/dropzone.min.css'); ?>">

Above body closing tag add DropzoneJS JavaScript file, jQuery library and DropzoneJS custom configuration file. We are using jQuery file in custom configuration file, for AJAX requests to backend.

<script src="<?php echo asset('vendor/dropzoner/dropzone/dropzone.min.js'); ?>"></script>
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.4/jquery.min.js"></script>
<script src="<?php echo asset('vendor/dropzoner/dropzone/config.js'); ?>"></script>

Including DropzoneJS upload widget

You can include DropzoneJS widget in your HTML with:

    @include('dropzoner::dropzone')

It will take full-width of parent div. That view consists of upload form and preview template.

Removal

By default each uploaded image will have Remove link. You can disable this feature once when you publish configuration file.

Events

Idea behind this package is to have plug and play functionality, but you may need to hook upload and delete action with your application so we have 2 events.

  • ImageWasUploaded
  • ImageWasDeleted

ImageWasUploaded has 2 properties: $original_filename and $server_filename ImageWasDeleted has 1 property: $server_filename

Example Listener

This is a simple listener for ImageWasUploaded events.

<?php

namespace App\Listeners;

use Codingo\Dropzoner\Events\ImageWasUploaded;

class ImageUploadListener
{
    /**
     * Example listener for image uploads
     * Event carries original_filename
     * and server_filename
     *
     * @param ImageWasUploaded $event
     */
    public function handle(ImageWasUploaded $event)
    {
        \Log::info('Inside ImageUploadListener, image was uploaded: ' . $event->server_filename);
    }
}

License

MIT License (MIT). See License File for more information.

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].