Giter Club home page Giter Club logo

capture's Introduction



File Capture

This package solves a file drag and drop problem on client side with ease!

Installation

$ npm i file-capture

All you have to do is to include capture.js script in your project

<script src="node_modules/file-capture/capture.js"></script>

Usage

Just initialize file capture object

let capture = new FileCapture()

And create a DOM element for file drop

<div class="file-capture"></div>

Now you can drag and drop files you want to be uploaded! In order to get file data which has been uploaded you can use getFiles method which returns a base64 of every uploaded file in one array

let data = capture.getFiles()

If you want Capture to research for newly created file-capture elements, you can use this method:

capture.update()

Configuration

Customization can be provided in a configuration object. Here is an example:

let capture = new FileCapture({
  types: ['image', 'audio', 'video', 'text', 'zip', 'application'],
  // These types are just an example... you can use any media type you want
  size: 5
  // Size is being given in megabytes (MB)
})

You can also create your own error behavior by editing error method of FileCapture instance.

capture.error = value => {
  console.error(`File ${value} is incorrect`)
  // value parameter can be equaled to either 'size' or 'type' depending on which one is incorrect
}

That's all for now... more features are coming soon...

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.