您的位置:首页 > Web前端 > JQuery

axios文件上传实现与jquery文件上传分别实现方式

2019-01-15 11:57 465 查看

axios文件上传实现

import Vue from 'vue'
import axios from 'axios';
var instance= axios.create({
baseURL:'https://www.********.com',
timeout:1000,
headers:{'Content-Type': 'multipart/form-data'}
});
Vue.config.productionTip=false;
Vue.prototype.instance=instance;
uploadFile : function (event,images) {
var formData = new FormData();
var vue = this;
formData.append("file",(event.target.files)[0]);
vue.instance.post('/index.php/service/common/uploadPicOther.html',formData)
.then(function (response) {
console.log(response);
})

jquery文件上传实现

$.ajax({
url: baseurl+'/index.php/service/common/uploadPicOther.html' ,
type: 'POST',
data: formData,
async: false,
cache: false,
processData: false,
contentType: false,
dataType:"json",
success: function (ret) {
console.log(ret);
},
});
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: 
相关文章推荐