<input id="fileupload" type="file" class="form-control" name="file" >
$("#fileupload").on("change",function(){
var file = this.files[0];
var data = new FormData();
data.append("file", file);
console.log(data);
console.log(file);
$.ajax({
type: "post",
url: " ",
data: data,
contentType: false,
//默认文件类型application/x-www-form-urlencoded 设置之后multipart/form-data
processData: false,
// 默认情况下会对发送的数据转化为对象 不需要转化的信息
success: function (res) {
source = res.picAddr;
},
});
})
jq / vue 图片直传阿里云
avoidaily2024-03-02 22:29
相关推荐
我的写法有点潮1 天前
Scss 的四种导入方式你都知道吗云飞云共享云桌面1 天前
SolidWorks对电脑的硬件配置要求具体有哪些鹏程十八少1 天前
11. Android <卡顿十一>深入ASM与Transform进行插桩,手写微信Matrix插件,打造自己的Matrix工具(卡顿进阶)李长鸿1 天前
vue3中的插槽和其他小桥风满袖1 天前
极简三分钟ES6 - 箭头函数bug_kada1 天前
前端后端3步联调:Cookie认证实战,让登录功能完美上线!stringwu1 天前
Flutter开发者必备:状态管理Bloc的实用详解青晚舟1 天前
作为前端你必须要会的CICDhj5914_前端新手1 天前
深入分析 —— JavaScript 深拷贝中微子1 天前
虚拟列表完全指南:从零到一手写实现