jquery实现文件页面表单提交
来源:互联网 发布:沪昆高铁贵州 知乎 编辑:程序博客网 时间:2024/05/05 14:15
<%@ page language="java" contentType="text/html; charset=UTF-8"
pageEncoding="UTF-8"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>Insert title here</title>
<script language="JavaScript" src="/js/jquery-1.8.3.js" ></script>
<script type="text/javascript">
function UpladFile() {
var fileObj = document.getElementById("file").files[0]; // 获取文件对象
var FileController = "http://192.168.23.174:8080/WeiKe/fileUpload?action=DruqwPmF1keVPn1s15Cy&userId=BC1000037589"; // 接收上传文件的后台地址
// FormData 对象
var form = new FormData();
form.append("author", "hooyes"); // 可以增加表单数据
form.append("file", fileObj); // 文件对象
// XMLHttpRequest 对象
var xhr = new XMLHttpRequest();
xhr.open("post", FileController, true);
xhr.onload = function () {
alert("上传完成!");
};
xhr.send(form);
}
</script>
</head>
<body>
<input type="file" id="file" name="myfile" />
<input type="button" onclick="UpladFile()" value="上传" />
</body>
</html>
pageEncoding="UTF-8"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>Insert title here</title>
<script language="JavaScript" src="/js/jquery-1.8.3.js" ></script>
<script type="text/javascript">
function UpladFile() {
var fileObj = document.getElementById("file").files[0]; // 获取文件对象
var FileController = "http://192.168.23.174:8080/WeiKe/fileUpload?action=DruqwPmF1keVPn1s15Cy&userId=BC1000037589"; // 接收上传文件的后台地址
// FormData 对象
var form = new FormData();
form.append("author", "hooyes"); // 可以增加表单数据
form.append("file", fileObj); // 文件对象
// XMLHttpRequest 对象
var xhr = new XMLHttpRequest();
xhr.open("post", FileController, true);
xhr.onload = function () {
alert("上传完成!");
};
xhr.send(form);
}
</script>
</head>
<body>
<input type="file" id="file" name="myfile" />
<input type="button" onclick="UpladFile()" value="上传" />
</body>
</html>
0 0
- jquery实现文件页面表单提交
- JQuery 实现表单提交
- jQuery Form 页面表单提交
- Jquery实现页面加载自动提交form表单
- jquery ajaxfileupload利用iframe表单提交实现ajax文件上传
- 使用jQuery.form插件实现表单异步提交+上传文件
- 使用jQuery.form插件实现表单异步提交+上传文件
- jQuery 实现form表单提交
- jquery查询页面表单进行提交
- 使用jquery.form.js 进行表单提交,通过回调函数实现页面互动
- 使用jquery.form.js 进行表单提交,通过回调函数实现页面互动功能。
- JQuery -AJAX- html中提交表单并实现不跳转页面处理返回值
- jquery实现form表单提交后局部刷新页面的多种方法
- 【jQuery】Jquery.form.js实现表单异步提交以及文件上传(带进度条)
- jquery mobile 表单提交 图片/文件 上传
- 实现ajax提交表单,页面不跳转
- jquery+struts+json实现表单提交
- 解析jquery实现回车键提交表单
- 乱码显示
- 求一个整数的二进制数中1的个数
- uboot配置过程详解1~2
- iOS 协议代理.block的基本使用
- 用maven新建模块cs-parent
- jquery实现文件页面表单提交
- 【bzoj3823】【定情信物】【递推】
- 报错:Could not load JDBC driver class [com.mysql.jdbc.Driver]
- hibernate两个表的联合查询 查询其中一个表
- 07-图6 旅游规划 (25分)
- freopen()妙用,输入输出重定义
- ts文件格式解析
- Thinking in java学习(一)
- 2015—2016年QS世界大学排名200强-[转]