[英]How to get selected file name and file path from input type file using jQuery
my code file name properly coming but file directory does not come. 我的代码文件名正确到来,但是文件目录没有到来。
my code 我的密码
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>jQuery Get Selected File Name</title>
<script type="text/javascript" src="http://code.jquery.com/jquery.min.js"></script>
<script type="text/javascript">
$(document).ready(function(){
$('input[type="file"]').change(function(e){
var fileName = e.target.files[0].dir;
alert('The file "' + fileName + '" has been selected.');
});
});
</script>
</head>
<body>
<form>
<input type="file">
</form>
</body>
</html>
how to solve this problem. 如何解决这个问题呢。 please help me solve this.
请帮我解决这个问题。 thanks.
谢谢。
https://developer.mozilla.org/en-US/docs/Web/API/File/name https://developer.mozilla.org/zh-CN/docs/Web/API/文件/名称
Returns the name of the file represented by a File object. 返回由File对象表示的文件的名称。 For security reasons, the path is excluded from this property.
出于安全原因,该路径从此属性中排除。
you can get the fileName but not path. 您可以获取文件名,但不能获取路径。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.