<!doctype html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="Generator" content="EditPlus®">
<meta name="Author" content="">
<meta name="Keywords" content="">
<meta name="Description" content="">
<title>Document</title>
</head>
<body>
<!-- <form method="post" action="" enctype="multipart/form-data">
<input type="file" id="f2">
<input type="submit" name="submit">
</form> -->
<input type="text">
<button type="button" class="button white">
本地导入
</button>
<button type="button">确认</button>
</body>
</html>
点击本地导入按钮 选择文件后 路径显示在input框中?
1.form表单提交

注意:
1.如果传输文件,需要设置enctype="multipart/form-data"
2.这种提交方式带来的弊端是会跳转页面
2.ajax方式提交


首先通过input标签获取到file对象,然后通过HTML5的FormData对象对file等信息进行封装
ajax中需要注意的是里面的参数配置
type:'POST'
contentType:'multipart/form-data'
processData:false//不改变传输数据中的对象
上面的代码还有另一种方式可以实现:

备注:avalon中的ajax不支持formdata传输