<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<title>文件上传</title>
</head>
<script type="text/javascript">
function checkFile(object) {
console.log(object)
var file = object.files[0];
if (typeof(file) == "undefined") {
return false;
} else {
var fileName = file.name;
console.log(fileName);
return true;
}
}
</script>
<body>
<h2 style="color: red;">本文作者:谷哥的小弟</h2>
<h2 style="color: red;">博客地址:http://blog.csdn.net/lfdfhl</h2>
<h2 style="color: red;">参考资料:https://www.w3.org/TR/file-upload/</h2>
<form action="" method="post" enctype="multipart/form-data">
文件描述:<input type="text" name="description" /><br /><br />
选择图片:<input type="file" name="image" onchange="checkFile(this)"/><br /><br />
<input type="submit" value="上传文件" />
</form>
</body>
</html>