<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312" />

<link rel="stylesheet" type="text/css" href="../images/style.css">
<title>图片上传</title>
<script src="jquery.js" language="javascript"></script>
</HEAD>
<BODY>
<script type="text/javascript"> 

function Preview(imgFile)
{ 
document.getElementById("pic").filters.item("DXImageTransform.Microsoft.AlphaImageLoader").src = imgFile.value;
}

var right_type=new Array(".jpg",".gif",".png",".jpeg")
function checkImgType(fileURL)
{
var right_typeLen=right_type.length;
var imgUrl=fileURL.toLowerCase();
var postfixLen=imgUrl.length;
var len4=imgUrl.substring(postfixLen-4,postfixLen);
var len5=imgUrl.substring(postfixLen-5,postfixLen);
for (i=0;i<right_typeLen;i++)
{
    if((len4==right_type[i])||(len5==right_type[i]))
    {
    return true;
    }
 }
}

 
function sub(o){
   if(o.file1.value==""){alert("请选择一个图片文件\n");return false;}

   if(checkImgType(o.file1.value)){
    perImg(o.file1.value);
    return true;
   }else{
   alert("您选择的文件格式不正确！");o.file1.focus();
   return false;
   }
}

</script> 

<form enctype="multipart/form-data" action="uploadgo.php?action=upload&types=single&tid=<?php echo $_GET['tid']?>" onSubmit="return sub(this)" name="uploadform" method="post">&nbsp;<input type="file" name= "file1" onChange="if(checkImgType(this.value)){Preview(this);}">
  <input name="action" type="hidden" value="upload" />
<input type="submit" value="上传图片">

</form>
</BODY>
</HTML>