Giter VIP home page Giter VIP logo

vue-simple-upload's Introduction

vue-simple-upload

npm npm vue2 Build Status

An simple file upload component for vue.js.

Checkout Demo on JSFiddle

Installation

npm install vue-simple-upload

Usage

vue-simple-upload is a UMD module, which can be used as a module in both CommonJS and AMD modular environments. When in non-modular environment, FileUpload will be registered as a global variable.

ES6

import FileUpload from 'vue-simple-upload/dist/FileUpload'

export default {
  ...
  components: {
    'fileupload': FileUpload
  },
  ...
}

After that, you can use it in your templates:

<fileupload target="http://localhost:8000/api/upload" action="POST"></fileupload>

CommonJS

var Vue = require('vue')
var FileUpload = require('vue-simple-upload')

var YourComponent = Vue.extend({
  ...
  components: {
    'fileupload': FileUpload.FileUpload
  },
  ...
})

Browser

<script src="path/to/vue/vue.min.js"></script>
<script src="path/to/vue-simple-upload/dist/vue-simple-upload.min.js"></script>
<script>
new Vue({
  ...
  components: {
    'fileupload': FileUpload.FileUpload
  },
  ...
})
</script>

Usage

<template>
<fileupload target="http://localhost:8000/api/upload" action="POST" v-on:progress="progress" v-on:start="startUpload" v-on:finish="finishUpload"></fileupload>
</template>

<script>
new Vue({
  ...
  components: {
    'fileupload': FileUpload.FileUpload
  },
  methods: {
    startUpload(e) {
      // file upload start event
      console.log(e);
    },
    finishUpload(e) {
      // file upload finish event
      console.log(e);
    },
    progress(e) {
      // file upload progress
      // returns false if progress is not computable
      console.log(e);
    }
  }
})
</script>

Props

  • target (String): Target endpoint to upload the file

  • action (String): Target action ( POST or PUT )

Events

You can access the file upload events using v-on methods.

  • File Upload start event: You can access the start event using v-on:start="startUpload"
methods() {
  startUpload(e) {
    // start event
  }
}
  • File Upload finish event: You can access the start event using v-on:finish="finishUpload"
methods() {
  finishUpload(e) {
    // finish event
  }
}
  • File Upload progress event: You can access the file upload progress using v-on:progress="progress"
methods() {
  progress(e) {
    // listen to file upload progress
  }
}

Todos

  • Multi File Upload

License

Released under the MIT License.

vue-simple-upload's People

Contributors

jchaos avatar saivarunk avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar

vue-simple-upload's Issues

Dynamic props ?

Heya all !

First, thanx for the component ... But was wondering how can i have a dynamic 'target' prop ? To have different target/folder ... Or how to pass more varibles to the xhr request ?

Thanx for your ideas

SyntaxError: Unexpected token export Using Webpack

Hey, first off, thanks for building something hugely useful!..
Secondly, I'm having a rough-time using it.

FileUpload.vue line: 6 Uncaught SyntaxError: Unexpected token export

package.json below... any ideas?

"dependencies": {
"axios": "^0.15.3",
"babel-polyfill": "^6.23.0",
"bootstrap-vue": "^0.5.1",
"chart.js": "^2.5.0",
"marker-clusterer-plus": "^2.1.4",
"sinon": "^2.1.0",
"update": "^0.7.4",
"vue": "^2.2.1",
"vue-axios": "^1.2.2",
"vue-chartjs": "^2.3.8",
"vue-material": "^0.6.3",
"vue-router": "^2.1.1",
"vue-simple-upload": "^0.1.6",
"vue-tables-2": "^0.3.0",
"vue2-google-maps": "^0.6.0",
"vuestrap-base-components": "^0.8.10",
"vuikit": "^0.6.2"
},

How to get file name after upload?

Hello.

Some question here... so how to get file name after upload?
I want it to save in my DB (using Django as backend for my API).

Thanks!

Couldn't find preset "es2015" relative to directory

When installing in a Vue 2.2.2 project, I get the following error when trying to use the plugin:

Module build failed: Error: Couldn't find preset "es2015" relative to directory \\node_modules\\vue-simple-upload"
    at \node_modules\babel-core\lib\transformation\file\options\option-manager.js:293:19
    at Array.map (native)
    at OptionManager.resolvePresets (\node_modules\babel-core\lib\transformation\file\options\option-manager.js:275:20)
    at OptionManager.mergePresets (\node_modules\babel-core\lib\transformation\file\options\option-manager.js:264:10)
    at OptionManager.mergeOptions (\node_modules\babel-core\lib\transformation\file\options\option-manager.js:249:14)
    at OptionManager.init (\node_modules\babel-core\lib\transformation\file\options\option-manager.js:368:12)
    at File.initOptions (\node_modules\babel-core\lib\transformation\file\index.js:216:65)
    at new File (\node_modules\babel-core\lib\transformation\file\index.js:139:24)
    at Pipeline.transform (\node_modules\babel-core\lib\transformation\pipeline.js:46:16)
    at transpile (\node_modules\babel-loader\lib\index.js:46:20)
    at Object.module.exports (\node_modules\babel-loader\lib\index.js:155:20)
 @ ./~/vue-simple-upload/dist/FileUpload.vue 3:2-94
 @ ./~/babel-loader/lib!./~/vue-loader/lib/selector.js?type=script&index=0!./src/components/pages/BnpBlacklist.vue
 @ ./src/components/pages/BnpBlacklist.vue
 @ ./src/router/index.js
 @ ./src/main.js
 @ multi ./build/dev-client ./src/main.js```

Target ERRO

Thank you for building a component like this. I installed everything just fine but when i set a target path and try to upload a file...it gives me this message:

"http://localhost:8080/manage/uploads 404 (Not Found)".

That directory exists.

Thanks!

How does Ajax take parameters when I upload a file?

<FileUpload 
    target="http://localhost:8000/api/upload"
    action="POST"
    v-on:progress="progress" 
    v-on:start="startUpload" 
    v-on:finish="finishUpload" />

How does Ajax take parameters when I upload a file? The README is not present!

56

Unknown custom element

1.) first of all, I'm NPM install vue-simple-upload in my project
2.) introduce import FileUpload from'vue-simple-upload/dist/FileUpload'on a new Vue page, components: {FileUpload}
3.) after that, use in my template
4.) page console error, said Unknown custom element: - did you register the component correctly? For recursive components, make sure to provide the "name" option.

Unknown plugin "transform-runtime"

Module build failed: ReferenceError: Unknown plugin "transform-runtime" specified in "/node_modules/vue-simple-upload/.babelrc"

Does this need to be installed?

XHR Response to upload

This package is missing vital element.
There should be server response with v-on:finish event.

For reference here's something like that on a similar package Vue-Clip onComplete event

I'll try to fiddle with it & send a PR if i can.

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.