将如下代码放入<head></head>中: <html><head> <script type="text/javascript" language="javascript"> <!-- function PreviewImg(imgFile,showPicDiv){ var newPreview = document.getElementById("newPreview"); var imgDiv = document.createElement("div"); document.body.appendChild(imgDiv); imgDiv.style.width = "118px"; imgDiv.style.height = "127px"; imgDiv.style.filter="progid:DXImageTransform.Microsoft.AlphaImageLoader(sizingMethod = scale)"; imgDiv.filters.item("DXImageTransform.Microsoft.AlphaImageLoader").src = imgFile.value; newPreview.appendChild(imgDiv); var showPicUrl = document.getElementById(showPicDiv); showPicUrl.innerText=imgFile.value; newPreview.style.width = "80px"; newPreview.style.height = "60px"; } --> </script> </head><body> 在页面中加入如下代码: <div id="newPreview"></div> <div id="showPicUrl"></div> <hr /> <p> 选择图片:<input type="file" size="20" onchange="javascript:PreviewImg(this,'showPicUrl');" /> </p> </body></html>