<form enctype="multipart/form-data">
<input type="file" name="myfile" onchange="loadFile(this.files[0])">
</form>
<script>
function loadFile(file){
var formdata = new FormData($$('form')[0]);
$.ajax({
url: 'jobs/add',
type: 'POST',
datatype: 'json',
data: formdata,
cache:false,
traditional: true,
contentType: false,
processData: false,
success: function (data) {},
error: function () {}
});
}
</script>
class Add:
def POST(self):
i = web.input(myfile={})
print(i['myfile'].filename) #文件名
print(i['myfile'].value) #文件内容
print(i['myfile'].file.read()) #文件内容
<input type="file" onchange="loadFile(this.files[0])" />
function loadFile(file){
container.fd = new FormData();
container.fd.append('myfile',file);
container.fd.append('otherkey',othervalue);
$.ajax({
url: 'jobs/add',
type: 'POST',
datatype: 'json',
data: fd,
cache:false,
traditional: true,
contentType: false,
processData: false,
success: function (data) {},
error: function () {}
});
}
class Add:
def POST(self):
i = web.input(myfile={}, otherkey='')
print(i['myfile'].filename) #文件名
print(i['myfile'].value) #文件内容
print(i['myfile'].file.read()) #文件内容
机械节能产品生产企业官网模板...
大气智能家居家具装修装饰类企业通用网站模板...
礼品公司网站模板
宽屏简约大气婚纱摄影影楼模板...
蓝白WAP手机综合医院类整站源码(独立后台)...苏ICP备2024110244号-2 苏公网安备32050702011978号 增值电信业务经营许可证编号:苏B2-20251499 | Copyright 2018 - 2025 源码网商城 (www.ymwmall.com) 版权所有