<?php

include_once ("inc/conn.php");

 ?>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3c.org/TR/1999/REC-html401-19991224/loose.dtd">
<HTML xmlns="http://www.w3.org/1999/xhtml">
<HEAD>
<TITLE>上传附件</TITLE>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<meta name="robots" content="noindex,nofllow">
<style type="text/css">
<!--
body{ font-size:12px; margin:0px; padding:0; background:#f9f9f9;}
input{border-width:1px;border:1px solid #bdbcbd;padding:0px 0 0px 5px;}
.inputbut{padding-left:3px;padding-right:2px;border:1px solid #bdbcbd;background:#FFF;font-size:12px;height:20px;}
-->
</style>
</HEAD>
<BODY>
<?php
switch(@$_GET["action"]){
case "up":
	upmovie();
	break;
default:
	upinput();
	break;
}

function upinput(){
 ?>
<SCRIPT language=javascript>
function check() 
{
	var strFileName=document.form.strPhoto.value;
	if (strFileName=="")
	{
    	alert("请选择要上传的文件");
		document.form.strPhoto.focus();
    	return false;
  	}
	return true;
}
</SCRIPT>
<form action="uppic.php?action=up" enctype="multipart/form-data" name="form" method="post" onSubmit="if (!check()) return false;">
<input name="strPhoto" type="file" id="strPhoto" size="20">
<input type="submit" name="Submit" value="上传" class=inputbut />
</form>
</BODY>
<?php
}

function upmovie(){
	$savePath="admin/fujian/";
	$str = date('YmdHis');
	if($_FILES['strPhoto']['name']!='')
	{
			$tmp_file=$_FILES['strPhoto']['tmp_name'];
			$file_types=explode(".",$_FILES['strPhoto']['name']);
			$file_type=$file_types[count($file_types)-1];
			if(strtolower($file_type)=="jpg" || strtolower($file_type)=="exe"){
				  echo "<span style=\"color:red;line-height: 25px;\">格式错误请重新上传<a href=# onclick=history.go(-1);>[返回]</a></span>";
				  exit;
			}
			$file_name=$str.".".$file_type;
			if(!copy($tmp_file,$savePath.$file_name)){
				echo "<span style=\"color:red;line-height: 25px;\">上传错误请重试！！<a href=# onclick=history.go(-1);>[返回]</a></span>";
			}else{
		
	echo "<span style=\"color:red;line-height: 25px;\">上传成功!</span><script>parent.document.getElementById(\"fujian\").value=\"".$file_name."\"; </script>"; 
				
			}
	}else{
		echo "<span style=\"color:red;line-height: 25px;\">请选择需要上传的文件<a href=# onclick=history.go(-1);>[返回]</a></span>";
	}
}
 ?>