New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

vue2-dropzone

Package Overview
Dependencies
Maintainers
1
Versions
52
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

vue2-dropzone

A wrapper around Dropzone.js for Vue 2

  • 2.2.4
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
46K
decreased by-11.27%
Maintainers
1
Weekly downloads
 
Created
Source

vue-dropzone

A Vue component for file uploads, powered by Dropzone.js. Check out the demo.

Install

// For Vue.js 2.0+
npm install vue2-dropzone@^2.0.0

You'll also need to load either the Material Icon or FontAwesome icon kits depending on which style of icon you'd like.

    <link href="https://fonts.googleapis.com/icon?family=Material+Icons"
      rel="stylesheet">
    <link href="https://maxcdn.bootstrapcdn.com/font-awesome/4.7.0/css/font-awesome.min.css" rel="stylesheet">

Usage

  1. Import the module
  2. Register it as a component as you would any other Vue component
  3. Use it within your template

Example

<template>
  <div id="app">
    <p>Welcome to your Vue.js app!</p>

    <dropzone id="myVueDropzone" url="https://httpbin.org/post" v-on:vdropzone-success="showSuccess"></dropzone>

  </div>
</template>

<script>
  import Dropzone from 'vue2-dropzone'

  export default {
    name: 'MainApp',
    components: {
      Dropzone
    },
    methods: {
      'showSuccess': function (file) {
        console.log('A file was successfully uploaded')
      }
    }
  }
</script>

Props

Many of these props are inherited from dropzone configuration so see their doco for further details.

Prop NameTypeDescription
idStringA string by which to identify the component, can be anything. Required
urlStringUrl to post the upload to. Required
clickableBooleanWhether the dropzone area is clickable, if false then users can only drag items on to the area.
acceptedFileTypesStringA comma separated string of accepted file types eg 'image/*,application/pdf,.psd' .
thumbnailHeightNumberThe height of thumbnails in pixels.
thumbnailWidthNumberThe width of thumbnails in pixels.
showRemoveLinkBooleanWhether the Remove link is shown on items.
maxFileSizeInMBNumberThe maximum file size for a single upload in MB.
maxNumberOfFilesNumberThe maximum number of files to allow the user to upload.
autoProcessQueueBooleanWhether the files are automatically uploaded or not.
useFontAwesomeBooleanWhether to use Font Awesome instead of Material Icon.
headersObjectIf you want to add additional headers.
languageObjectUse dropzone's dict properties to change texts.
useCustomDropzoneOptionsBooleanIf you want to define your own dropzone config set this to true and define a dropzoneOptions.
dropzoneOptionsObjectA custom set of rules to define your dropzone object, use anything available in the dropzone config.

Methods

Methods you can call on the component.

MethodDescription
setOption(optionname, value)Sets the value of one of the dropzone options after initialisation. Handy if you need to pass through a token after the component has initialised.
removeAllFiles()Empties the dropzone area.
processQueue()Uploads the files, required if autoProcessQueue is set to false.
removeFile(file)Removes a file from the dropzone area.

##Using Methods Methods can be called from your parent component by making use of the special tag "ref".

When you initialize the compnonent add a unique ID to the dropzone element using the ref tag, like this

<dropzone ref="myUniqueID"></dropzone>

Then from your parent Vue instance, you can call the methods by using the following:

vm.$refs.myUniqueID.processQueue()
//vm refers to your current instance

Events

Events emitted by the component to the parent.

Event NameDescription
vdropzone-file-added(file)File added to the dropzone.
vdropzone-success(file, response)File successfully uploaded.
vdropzone-error(file)File uploaded encountered an error.
vdropzone-removed-file(file, error, xhr)A file was removed from the dropzone.
vdropzone-sending(file, xhr, formData)Modify the request and add addtional parameters to request before sending.
vdropzone-success-multiple(files, response)Fired if the uploadMultiple option is true.
vdropzone-sending-multiple(files, xhr, formData)Fired if the uploadMultiple option is true.

Development

# install dependencies
npm install

# serve example at localhost:8080
npm run dev

# build any changes made
npm run build

FAQs

Package last updated on 13 Mar 2017

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc