Javascript 如何使用<;输入>;

Javascript 如何使用<;输入>;,javascript,html,Javascript,Html,我希望能够有我的用户输入到网页的图像。 一旦他们从电脑中导入文件,图像就会显示在img中 <body> <img id="myImage" height="200px" width="200px"> <input type="file" id="ImageInput" oninput="changeImage()"> <script> function changeImage(){ /

我希望能够有我的用户输入到网页的图像。 一旦他们从电脑中导入文件,图像就会显示在img中

<body>
    <img id="myImage" height="200px" width="200px">
    <input type="file" id="ImageInput" oninput="changeImage()">
    <script>
        function changeImage(){
            //def each element involved
            imageBox=document.getElementById("myImage");
            inputBox=document.getElementById("ImageInput");

            //set link from input box to image box link
            console.log(inputBox.files[0])
            imageBox.setAttribute("src",inputBox.files[0].name);
        }
    </script>
</body>

此代码找不到导入的图像,因此不执行任何操作,并提取错误ERR_FILE_NOT_FOUND


目前我认为它只是试图在本地查找文件,但失败了,因为它不在本地目录中,但我不确定。

设置名称将不起作用
this.files[0]。mozFullPath
请尝试设置正确的文件路径