Created
December 8, 2016 08:36
-
-
Save tianyk/1c2fd6b8ce0ee602d6acaadd8801b01a to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<html> | |
<head> | |
<title>文件上传</title> | |
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> | |
</head> | |
<body> | |
<form id="uploadForm" enctype="multipart/form-data"> | |
<input id="file" type="file" name="file" /> | |
<button id="upload" type="button">upload</button> | |
</form> | |
</body> | |
<script src="http://cdn.bootcss.com/jquery/2.2.3/jquery.js"></script> | |
<script> | |
$(() => { | |
$('#upload').click(() => { | |
$.ajax({ | |
url: '/upload', | |
type: 'POST', | |
cache: false, | |
data: new FormData($('#uploadForm')[0]), | |
processData: false, | |
contentType: false | |
}) | |
.done((res) => { }) | |
.fail((res) => { }); | |
}); | |
}); | |
</script> | |
</html> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment