Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/javascript/419.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Javascript 如何在html5中获取导入图像的文件路径_Javascript_Html - Fatal编程技术网

Javascript 如何在html5中获取导入图像的文件路径

Javascript 如何在html5中获取导入图像的文件路径,javascript,html,Javascript,Html,我正在尝试获取html5中导入图像的文件路径。 我当前的HTML代码如下所示: <!DOCTYPE HTML> <html> <head> <title>example.com</title> <link rel="stylesheet" type="text/css" href="Index.css"> </head> <body>

我正在尝试获取html5中导入图像的文件路径。 我当前的HTML代码如下所示:

<!DOCTYPE HTML>
<html>
    <head>
        <title>example.com</title>
        <link rel="stylesheet" type="text/css" href="Index.css">
    </head>
    <body>
        <h1>Example.com</h1>
        <p>Import image: <input type="file" accept="image/x-png" onclick="importImage()" id="importImg"></p>
        <script src="JS.js"></script>
    </body>
</html>

example.com
Example.com
导入图像:

我还没有任何JS代码,因为我根本不知道怎么做
也没有css,因为我刚开始这个项目,但我不认为这是必要的。我没有完全理解你的问题。但我想你们需要输入类型文件的系统路径

从系统中获取文件的完整路径

$('input[type=file]').change( function(event) {
    var tmppath = URL.createObjectURL(event.target.files[0]);
   console.log(tmppath)
});

欢迎来到StackOverflow。阅读HTML中表单如何工作的文档使用
change
函数进行文件输入,然后获取文件路径,如
console.log(this.files[0].mozzullpath)请注意,您无法在浏览器中获取完整的文件路径。但是,你为什么需要它?