Giter VIP home page Giter VIP logo

vue-file-upload-component's Introduction

vue-file-upload-component

A simple file upload component for Vue.js. Emits events for XHR Upload Progress for nice progress bars.

I came up with the original idea when looking at this repo. I knew I wanted a nice component with upload progress and so I copied some code from that library.

Install

Available through npm as vue-file-upload-component. Or include as an inline script, like in example.html.

Demo

In order to use the demo, you need to have PHP setup and this project running under a server. There is a script in the root called upload.php, which is a simple script to handle single file uploads. Most likely you will have your own way of handling files.

Setting Headers

You can set headers for the submission by using the attribute v-bind:headers="xhrHeaders". xhrHeaders may look something like this:

// ... Vue stuff above
data: {
  xhrHeaders: {
    "X-CSRF-TOKEN": "32charactersOfRandomStringNoise!"
  }
},
// ... more stuff below

You can set many headers in the object.

Caveats

This upload script only uploads 1 file at a time. The upload handler uses Promises internally to know when all the files are uploaded.

If you are using Internet Explorer, you will probably need a polyfill. I have used this one before and it is small and well tested.

You also need support for FormData but it has higher support than Promises so you are probably fine.

vue-file-upload-component's People

Contributors

james2doyle avatar yalab avatar

Watchers

James Cloos avatar jinxiaochuan avatar

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.