<!DOCTYPE html>
<html>
<head>
<title>上传</title>
<script src="/scripts/jquery/jquery-1.192.min.js"></script>
<script>
function uploadfile() {
$.ajax({
url: '/Upload.ashx',
type: 'POST',
cache: false,
data: new FormData($('#uploadForm')[0]),
processData: false,
contentType: false
}).done(function (res) {
$("#out").html(res);
}).fail(function (res) {
$("#out").html(res);
});
}
</script>
<style>
</style>
</head>
<body>
选择文件后上传
<form id="uploadForm" enctype="multipart/form-data">
<input id="file" type="file" name="file" />
<input type='hidden' name='input' value=''>
<button id="upload" type="button" onclick="uploadfile()">上传</button>
</form>
<div id="out"><div>
</body>
</html>
ajax上传文件
最新推荐文章于 2022-10-27 14:47:48 发布