file

file

vue multiple type="file" 多文件上传

VUElopo1983 发表了文章 • 0 个评论 • 2839 次浏览 • 2017-04-13 02:56 • 来自相关话题

template<input class="hide" multiple type="file" name="fileup" id="upfile" accept="application/x-zip-compressed" value="" @change="onFileChange" multiple="multiple" />
<label class="btn btn-default" for="upfile">选择文件</label>?
methodsonFileChange(e) {
const files = e.target.files || e.dataTransfer.files;
let a =
Array.from(files, item => {
a.push({
name: item.name,
type: item.name.split('.')[1]
})
});
this.arrfile = a;
}
发送(使用axios FormData)addChat(oid, def) {
let data = new FormData(def);
data.append('uid', window.USER_ID);
data.append('oid', oid);
data.append('guest',true)
return fetch('chat', data);
}sendChat() {
let def = this.$refs.chatform;
api.addChat(this.getOid, def).then(response => {
if(!!response) {
this.getChat()
} else {
alert("非法操作")
}
}), response => {
this.loading = false;
this.errorinfo = "加载失败....服务器出小差了"
}
}
? 查看全部
template
<input class="hide" multiple type="file" name="fileup" id="upfile" accept="application/x-zip-compressed" value="" @change="onFileChange" multiple="multiple" />
<label class="btn btn-default" for="upfile">选择文件</label>
?
methods
onFileChange(e) {
const files = e.target.files || e.dataTransfer.files;
let a =
Array.from(files, item => {
a.push({
name: item.name,
type: item.name.split('.')[1]
})
});
this.arrfile = a;
}

发送(使用axios FormData)
addChat(oid, def) {
let data = new FormData(def);
data.append('uid', window.USER_ID);
data.append('oid', oid);
data.append('guest',true)
return fetch('chat', data);
}
sendChat() {
let def = this.$refs.chatform;
api.addChat(this.getOid, def).then(response => {
if(!!response) {
this.getChat()
} else {
alert("非法操作")
}
}), response => {
this.loading = false;
this.errorinfo = "加载失败....服务器出小差了"
}
}

?

vue multiple type="file" 多文件上传

VUElopo1983 发表了文章 • 0 个评论 • 2839 次浏览 • 2017-04-13 02:56 • 来自相关话题

template<input class="hide" multiple type="file" name="fileup" id="upfile" accept="application/x-zip-compressed" value="" @change="onFileChange" multiple="multiple" />
<label class="btn btn-default" for="upfile">选择文件</label>?
methodsonFileChange(e) {
const files = e.target.files || e.dataTransfer.files;
let a =
Array.from(files, item => {
a.push({
name: item.name,
type: item.name.split('.')[1]
})
});
this.arrfile = a;
}
发送(使用axios FormData)addChat(oid, def) {
let data = new FormData(def);
data.append('uid', window.USER_ID);
data.append('oid', oid);
data.append('guest',true)
return fetch('chat', data);
}sendChat() {
let def = this.$refs.chatform;
api.addChat(this.getOid, def).then(response => {
if(!!response) {
this.getChat()
} else {
alert("非法操作")
}
}), response => {
this.loading = false;
this.errorinfo = "加载失败....服务器出小差了"
}
}
? 查看全部
template
<input class="hide" multiple type="file" name="fileup" id="upfile" accept="application/x-zip-compressed" value="" @change="onFileChange" multiple="multiple" />
<label class="btn btn-default" for="upfile">选择文件</label>
?
methods
onFileChange(e) {
const files = e.target.files || e.dataTransfer.files;
let a =
Array.from(files, item => {
a.push({
name: item.name,
type: item.name.split('.')[1]
})
});
this.arrfile = a;
}

发送(使用axios FormData)
addChat(oid, def) {
let data = new FormData(def);
data.append('uid', window.USER_ID);
data.append('oid', oid);
data.append('guest',true)
return fetch('chat', data);
}
sendChat() {
let def = this.$refs.chatform;
api.addChat(this.getOid, def).then(response => {
if(!!response) {
this.getChat()
} else {
alert("非法操作")
}
}), response => {
this.loading = false;
this.errorinfo = "加载失败....服务器出小差了"
}
}

?