<?php
require_once("../../include/label.php");
if(isset($_COOKIE["s_id"])){
	$S_UID=$_COOKIE["s_id"];
}
else{
	$S_UID="";
}
if(isset($_COOKIE["s_name"])){
	$S_Name=$_COOKIE["s_name"];
}
else{
	$S_Name="";
}
$sql= "select s_id from s_users where S_Name='".$S_Name."' and S_id=$S_UID";
$s_id= $db->Getone($sql);
if(!$s_id){
      exit("请先登入！");
}
?>
<!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" />
<title>图片上传</title>
<script src="../js/jquery.js" language="javascript"></script>
<style type="text/css" media="all">
<!--
input{ background:#F9F9F9;color:#555;font:12px "Lucida Grande", Verdana, Lucida, Helvetica, Arial, "宋体", sans-serif}
-->
</style>
</HEAD>
<BODY>
<script type="text/javascript"> 
document.oncontextmenu=new Function("event.returnValue=false;"); 
document.onselectstart=new Function("event.returnValue=false;"); 

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

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