All Projects → Yaxian → vue3-dropzone

Yaxian / vue3-dropzone

Licence: MIT License
HTML5 drag-drop zone with vue3

Programming Languages

typescript
32286 projects
javascript
184084 projects - #8 most used programming language

Projects that are alternatives of or similar to vue3-dropzone

image-uploader
Simple Drag & Drop image uploader plugin to static forms, without using AJAX
Stars: ✭ 70 (+105.88%)
Mutual labels:  drag-and-drop, file-upload
React Dropzone
Simple HTML5 drag-drop zone with React.js.
Stars: ✭ 8,639 (+25308.82%)
Mutual labels:  drag-and-drop, file-upload
Dropzone
Dropzone is an easy to use drag'n'drop library. It supports image previews and shows nice progress bars.
Stars: ✭ 16,097 (+47244.12%)
Mutual labels:  drag-and-drop, file-upload
vite-vue3-lowcode
vue3.x + vite2.x + vant + element-plus H5移动端低代码平台 lowcode 可视化拖拽 可视化编辑器 visual editor 类似易企秀的H5制作、建站工具、可视化搭建工具
Stars: ✭ 1,309 (+3750%)
Mutual labels:  drag-and-drop, vue3
Ipfs Dropzone
Dropzone.js that uploads to IPFS instead of to an URL
Stars: ✭ 151 (+344.12%)
Mutual labels:  drag-and-drop, file-upload
vue-simple-upload-component
A simple upload component for Vue.js 2.x
Stars: ✭ 14 (-58.82%)
Mutual labels:  drag-and-drop, file-upload
Filepond Boilerplate Php
🔥 A FilePond PHP project starter kit
Stars: ✭ 45 (+32.35%)
Mutual labels:  drag-and-drop, file-upload
yii2-dropzone
This extension provides the Dropzone integration for the Yii2 framework.
Stars: ✭ 11 (-67.65%)
Mutual labels:  drag-and-drop, file-upload
Filepond
🌊 A flexible and fun JavaScript file upload library
Stars: ✭ 11,869 (+34808.82%)
Mutual labels:  drag-and-drop, file-upload
React File Drop
React component for Gmail or Facebook -like drag and drop file uploader
Stars: ✭ 123 (+261.76%)
Mutual labels:  drag-and-drop, file-upload
Spring Boot Projects
该仓库中主要是 Spring Boot 的入门学习教程以及一些常用的 Spring Boot 实战项目教程,包括 Spring Boot 使用的各种示例代码,同时也包括一些实战项目的项目源码和效果展示,实战项目包括基本的 web 开发以及目前大家普遍使用的线上博客项目/企业大型商城系统/前后端分离实践项目等,摆脱各种 hello world 入门案例的束缚,真正的掌握 Spring Boot 开发。
Stars: ✭ 4,022 (+11729.41%)
Mutual labels:  file-upload, vue3
react-butterfiles
🦋 Component for building file fields - from basic file inputs to drag and drop image galleries.
Stars: ✭ 44 (+29.41%)
Mutual labels:  drag-and-drop, file-upload
React Uploady
Modern file uploading - components & hooks for React
Stars: ✭ 372 (+994.12%)
Mutual labels:  drag-and-drop, file-upload
Angular File Uploader
Angular file uploader is an Angular 2/4/5/6/7/8/9/10 + file uploader module with Real-Time Progress Bar, Responsive design, Angular Universal Compatibility, localization and multiple themes which includes Drag and Drop and much more.
Stars: ✭ 92 (+170.59%)
Mutual labels:  drag-and-drop, file-upload
File Drop
A simple file drag and drop custom-element
Stars: ✭ 188 (+452.94%)
Mutual labels:  drag-and-drop, file-upload
vue3-smooth-dnd
Vue3 wrapper components for smooth-dnd
Stars: ✭ 92 (+170.59%)
Mutual labels:  drag-and-drop, vue3
electron-vue-vite-boilerplate
Electron Vue Vite Boilerplate for you next project
Stars: ✭ 26 (-23.53%)
Mutual labels:  vue3
rc-dock
Dock Layout for React Component
Stars: ✭ 318 (+835.29%)
Mutual labels:  drag-and-drop
hoc-element-table
📦 A Vue 3.x Table Component built on Webpack 5
Stars: ✭ 26 (-23.53%)
Mutual labels:  vue3
v-bucket
📦 Fast, Simple, and Lightweight State Manager for Vue 3.0 built with composition API, inspired by Vuex.
Stars: ✭ 42 (+23.53%)
Mutual labels:  vue3

vue3-dropzone

It's inspired by react-dropzone and implemented with vue3.

Installation

npm install --save vue3-dropzone

or

yarn add vue3-dropzone

Usage

Basic use with flexibility. acceptFiles is an array returned in the same format as FileList where all the dropped files are turned into a File class before saving to the array.

<template>
  <div>
    <div v-bind="getRootProps()">
      <input v-bind="getInputProps()" />
      <p v-if="isDragActive">Drop the files here ...</p>
      <p v-else>Drag 'n' drop some files here, or click to select files</p>
    </div>
    <button @click="open">open</button>
  </div>
</template>

<script>
import { useDropzone } from "vue3-dropzone";

export default {
  name: "UseDropzoneDemo",
  setup() {
    function onDrop(acceptFiles, rejectReasons) {
      console.log(acceptFiles);
      console.log(rejectReasons);
    }

    const { getRootProps, getInputProps, ...rest } = useDropzone({ onDrop });

    return {
      getRootProps,
      getInputProps,
      ...rest,
    };
  },
};
</script>


Save multiple files

Save multiple files through axios requests and FormData. You will need a backend to loop through the received files and save them individually in the loop.

<template>
  <div>
    <div v-bind="getRootProps()">
      <input v-bind="getInputProps()" />
      <p v-if="isDragActive">Drop the files here ...</p>
      <p v-else>Drag 'n' drop some files here, or click to select files</p>
    </div>
    <button @click="open">open</button>
  </div>
</template>

<script>
import { useDropzone } from "vue3-dropzone";
import axios from "axios";

export default {
  name: "UseDropzoneDemo",
  setup() {
    const url = "{your_url}"; // Your url on the server side
    const saveFiles = (files) => {
      const formData = new FormData(); // pass data as a form
      for (var x = 0; x < files.length; x++) {
        // append files as array to the form, feel free to change the array name
        formData.append("images[]", files[x]);
      }

      // post the formData to your backend where storage is processed. In the backend, you will need to loop through the array and save each file through the loop.

      axios
        .post(url, formData, {
          headers: {
            "Content-Type": "multipart/form-data",
          },
        })
        .then((response) => {
          console.info(response.data);
        })
        .catch((err) => {
          console.error(err);
        });
    };

    function onDrop(acceptFiles, rejectReasons) {
      saveFiles(acceptFiles); // saveFiles as callback
      console.log(rejectReasons);
    }

    const { getRootProps, getInputProps, ...rest } = useDropzone({ onDrop });

    return {
      getRootProps,
      getInputProps,
      ...rest,
    };
  },
};
</script>

API

const result = useDropzone(options)

options

property type description
onDrop Function Cb for when the drop event occurs. Note that this callback is invoked after the getFilesFromEvent callback is done.
accept String / Array<*String> Set accepted file types. See https://github.com/okonet/attr-accept for more information.
disabled Boolean Enable/disable the dropzone
maxSize Number Maximum file size (in bytes)
minSize Number Minimum file size (in bytes)
multiple Number Allow of multiple files
maxFiles Number Maximum accepted number of files The default value is 0 which means there is no limitation to how many files are accepted
getFilesFromEvent Function Use this to provide a custom file aggregator
onDragEnter Function Cb for when the dragenter event occurs.
onDragenter Function Cb for when the dragenter event occurs.
onDragOver Function Cb for when the dragover event occurs
onDragover Function Cb for when the dragover event occurs
onDragLeave Function Cb for when the dragleave event occurs
onDragleave Function Cb for when the dragleave event occurs
onDropAccepted Function Cb for when the drop event occurs. Note that if no files are accepted, this callback is not invoked.
onDropRejected Function Cb for when the drop event occurs. Note that if no files are rejected, this callback is not invoked.
onFileDialogCancel Function Cb for when closing the file dialog with no selection
preventDropOnDocument Boolean If false, allow dropped items to take over the current browser window
noClick Boolean If true, disables click to open the native file selection dialog
noKeyboard Boolean If true, disables SPACE/ENTER to open the native file selection dialog. Note that it also stops tracking the focus state.
noDrag Boolean If true, disables drag 'n' drop
noDragEventsBubbling Boolean If true, stops drag event propagation to parents

result

property type description
isFocused Ref<Boolean>
isFileDialogActive Ref<Boolean>
isDragActive Ref<Boolean>
isDragAccept Ref<Boolean>
isDragReject Ref<Boolean>
draggedFiles Ref<Array> dragged files
acceptedFiles Ref<Array> accepted files
fileRejections Ref<Array> files rejections
getRootProps Function Function to generate element props which contains input
getInputProps Function Function to generate input props
rootRef Ref<*HTMLElement> ref a dom element
inputRef Ref<*HTMLElement> ref a input element
open Function Open file selection dialog

Run example

cd examples
yarn install
yarn dev
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].