相同的.html 文件,用JS实现图片预览,直接打开时能实现预览,可在tomcat下运行就不行了.太奇怪了!!!!!!!
这是怎么回事啊?????????????????????代码如下:
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312">
<title>图片上传</title>
<script>
function yulan()
{
if(document.all.form1.user_photo.value)
{
document.all.form1.viewpic.src=document.all.form1.user_photo.value;
document.all.form1.viewpic.style.display="";
document.all.form1.viewpic.border=1;
}
}
</script>
</head>
<body>
<center>
<form name="form1" id="form1">
<img name="viewpic" id="viewpic" width="359" height="286"><input type="file" name="user_photo" id="user_photo" onChange="yulan();"></form></center>
</body>
</html>
这是怎么回事啊?????????????????????代码如下:
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312">
<title>图片上传</title>
<script>
function yulan()
{
if(document.all.form1.user_photo.value)
{
document.all.form1.viewpic.src=document.all.form1.user_photo.value;
document.all.form1.viewpic.style.display="";
document.all.form1.viewpic.border=1;
}
}
</script>
</head>
<body>
<center>
<form name="form1" id="form1">
<img name="viewpic" id="viewpic" width="359" height="286"><input type="file" name="user_photo" id="user_photo" onChange="yulan();"></form></center>
</body>
</html>
解决方案 »
- 奇怪的spring事物
- 高手看看 split简单问题
- 并发时,数据库连接超时
- 在一个JSP页面中,可以返回两个不同的ResultSet吗
- 如何点"打印"按钮后,打印另外一页的内容?
- 安装mysql-connector-java-3.1.10.zip的问题
- 我在编写一个jsp页面的时候用到了javax.mail.*这个套件,那么我只能用安装j2ee这个方法来使tomcat能够在运行时能够编译这个jsp页面吗?有
- .
- jsp转ASP碰到的第一个连接数据库问题,请教高手(在线等,急)顺便说说我在杭州找工作的经历
- 问Tomcat启动时候的问题!(急)
- 奇怪的问题,重新获取验证码失效
- 求上传图片及其方法例子 jsp的
你的图片预览取的是本地路径,也就是绝对路径
当你直接打开文件的时候自然能看
而用TOMCAT打开需要的是相对路径,自然找不到文件,也就没预览了
就是说在TOMCAT下无法实现预览效果了?