# 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](https://github.com/tj/s3.js). 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
![](http://cl.ly/image/3k2M2I0f4417/Screen%20Recording%202015-12-04%20at%2008.58%20AM.gif)
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:
```json
// ... 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](https://github.com/getify/native-promise-only) and it is small and well tested.
You also need [support for FormData](https://developer.mozilla.org/en-US/docs/Web/API/FormData) but it has higher support than `Promises` so you are probably fine.
没有合适的资源?快使用搜索试试~ 我知道了~
一个简单的Vue.js文件上传组件 为XHR上传进度发出事件以获得漂亮的进度条 -JavaScript-HTML-下载
共11个文件
js:3个
php:1个
license:1个
1.该资源内容由用户上传,如若侵权请联系客服进行举报
2.虚拟产品一经售出概不退款(资源遇到问题,请及时私信上传者)
2.虚拟产品一经售出概不退款(资源遇到问题,请及时私信上传者)
版权申诉
0 下载量 87 浏览量
2023-03-16
22:45:10
上传
评论
收藏 10KB ZIP 举报
温馨提示
(更多详情、使用方法,请下载后细读README.md文件) 'vue-文件上传组件 一个简单的 Vue.js 文件上传组件。为 XHR 上传进度发出事件以获得漂亮的进度条。 在查看此 repo时,我想到了最初的想法。我知道我想要一个带有上传进度的好组件,所以我从那个库中复制了一些代码。 安装 可通过 npm 作为vue-file-upload-ponent. 或者作为内联脚本包含在内,例如 in example.html. 演示 为了使用演示,您需要安装 PHP 并且该项目在服务器下运行。根目录中有一个名为 的脚本upload.php,这是一个处理单个文件上传的简单脚本。您很可能会有自己的文件处理方式。 设置标题 您可以使用属性为提交设置标题v-bindheaders=\\xhrHeaders\\。xhrHeaders可能看起来像这样: ... Vue stuff above data { xhrHeaders { \\X-CSRF-TOKEN\\ \\32charactersOfRandomStringNoise!\\ } }, ... more stuff be
资源推荐
资源详情
资源评论
收起资源包目录
一个简单的Vue.js文件上传组件。为XHR上传进度发出事件以获得漂亮的进度条。.zip (11个子文件)
vue-file-upload-component-master
.editorconfig 182B
gulpfile.js 433B
upload.php 1KB
.jshintrc 3KB
LICENSE 1KB
example.html 3KB
package.json 653B
vue.pretty-bytes.js 713B
.gitignore 879B
README.md 2KB
vue.file-upload.js 4KB
共 11 条
- 1
资源评论
快撑死的鱼
- 粉丝: 1w+
- 资源: 9156
上传资源 快速赚钱
- 我的内容管理 展开
- 我的资源 快来上传第一个资源
- 我的收益 登录查看自己的收益
- 我的积分 登录查看自己的积分
- 我的C币 登录后查看C币余额
- 我的收藏
- 我的下载
- 下载帮助
安全验证
文档复制为VIP权益,开通VIP直接复制
信息提交成功