Javascript 从';文件';img字段中未显示类型输入字段

Javascript 从';文件';img字段中未显示类型输入字段,javascript,html,file-upload,image,Javascript,Html,File Upload,Image,我无法使用javascript更改文件上载时显示的图像。这是我的代码: 文件上传 函数uploadFile(){ document.getElementById('picturefield').src='file://'+document.frmadstudent.picturefile.src; //document.getElementById('picturefield').src='10〕http://icons.iconarchive.com/icons/custom-icon-d

我无法使用javascript更改文件上载时显示的图像。这是我的代码:


文件上传
函数uploadFile(){
document.getElementById('picturefield').src='file://'+document.frmadstudent.picturefile.src;
//document.getElementById('picturefield').src='10〕http://icons.iconarchive.com/icons/custom-icon-design/pretty-office-2/128/man-icon.png';
}
形象
但是,从我的电脑上传文件时,图像没有被更改
document.frmadstudent.picturefile.src
使用firebug调试时显示空字符串

如果我使用
document.frmadstudent.picturefile.value
而不是
document.frmadstudent.picturefile.src
, 然后该值仅显示所选文件名,但我需要完整的文件路径设置为
img
src


谁能告诉我我在这里做错了什么?Javascript/jQuery中有什么简单的解决方案可以做到这一点吗?

出于安全原因,现代浏览器不支持输入文件的这一功能


您必须上传该文件,然后在
img

中显示它。不,Mozilla中有一种叫做文件阅读器的东西,在许多浏览器中都受支持。除了IEOk之外,我想知道plz在这里发布这个解决方案。这个解决方案需要IE上的脚本/Activex运行确认,但仍然是一个好的解决方案,我不知道+1。没有检查@AnkitGautam的链接,因为我也需要它来处理IE。似乎我必须避免这样做,而是用另一种方式(可能是瑜伽士建议的)看代码
<html>
<head>
    <title> File Upload </title>
    <script>
        function uploadFile() {
            document.getElementById('picturefield').src='file:///'+document.frmaddstudent.picturefile.src;
            //document.getElementById('picturefield').src='http://icons.iconarchive.com/icons/custom-icon-design/pretty-office-2/128/man-icon.png';
        }
    </script>
</head>

<body>
    <b>Image</b>
    <form name="frmaddstudent">
        <img id="picturefield" src="file:///C:/Users/Nasim/Desktop/myimage.jpg">
        <input type="file" name="picturefile" onchange="uploadFile()">
    </form>
</body>
</html>