<html>
<head>
<title>test upload picture</title>
<script language="javascript">
function testviewpic(mypic,imgfilepath)
{
 var myflag=0; //进行筛选的图片的扩展名
 var aa = ".gif|.jpg|.jpeg|.bmp|.png"; //分离出可以通过的图片扩展名
 var bb = aa.split('|'); //进行循环判断,路经是否为图片
 for(var i=0;i<bb.length;i++)
 {
  //检索路径是否含有指定图片的扩展名
  var cc = imgfilepath.value.toLowerCase().indexOf(bb[i]);
  if (cc > 0)
  {
   //当图片的路经中含有指定的扩展名时,对状态进行赋值
   myflag=1; mypic.src=imgfilepath.value; mypic.style.display=""; mypic.border=1; break;
  }
 }
 //如果状态为错误,弹出信息框
 if(myflag == 0)
 {
  alert("current path not picture"); //清除上传框的路径值
  imgfilepath.outerHTML = imgfilepath.outerHTML; imgfilepath.value=""; mypic.src=""; mypic.style.display="none";
 }
}
</script>
</head>
<body>
<form >
<table>
<tr>
<td class="tdLeft">图片上传:</td>
<td><INPUT > </td> </tr>
<tr> <td class="tdLeft"></td> <td><img ></td> </tr> </table>
</form>
</body>
</html>

相关文章:

  • 2022-02-10
  • 2021-07-28
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2021-11-19
  • 2022-12-23
猜你喜欢
  • 2021-07-31
  • 2022-01-14
  • 2022-12-23
  • 2022-12-23
  • 2022-01-01
  • 2022-12-23
  • 2021-05-31
相关资源
相似解决方案