<html>
<head>
<title>文件上传</title>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312">
<style type="text/css">
<!--
td{font-size:12px}
a{color:#000000;text-decoration: none}
a:hover{text-decoration: underline}
.tx{height:16px;width:30px;border-color:black black #000000;border-top-width:0px;border-right-width: 0px; border-bottom-width: 1px; border-left-width: 0px; font-size: 12px; background-color: #eeeeee; color: #0000FF}
.button{font-size:12px;border-top-width:0px;border-right-width:0px;border-bottom-width:0px;border-left-width: 0px; height: 16px; width: 80px; background-color: #FF9966; cursor: hand}
.tx1{height:20px;width:30px;font-size:12px;border:1px solid;border-color:black black #000000;color: #0000FF}
-->
</style>
<script language="javascript">
<!--
function mysub()
{
		esave.style.visibility="visible";
}
-->
</script>
</head>
<body bgcolor="#FFFFFF" text="#000000">
<form enctype="multipart/form-data" method="post" action="?ac=go">
  <div id="esave" style="position:absolute; top:18px; left:40px; z-index:10; visibility:hidden"> 
    <TABLE WIDTH=340 BORDER=0 CELLSPACING=0 CELLPADDING=0>
      <TR><td width=20%></td>
	<TD bgcolor=#104A7B width="60%"> 
	<TABLE WIDTH=100% height=120 BORDER=0 CELLSPACING=1 CELLPADDING=0>
	<TR> 
	          <td bgcolor=#eeeeee align=center><font color=red>正在上传文件，请稍候...</font></td>
	</tr>
	</table>
	</td><td width=20%></td>
	</tr></table></div>
  <table width="400" border="1" cellspacing="0" cellpadding="3" align="center" bordercolordark="#779FDC" bordercolorlight="#779FDC">
    <tr bgcolor="#FFCC00"> 
      <td height="22" align="left" valign="middle" bgcolor="#D6DFF7" width="400">&nbsp;文件上传 </td>
    </tr><input type="hidden" name="MAX_FILE_SIZE" value="500000000" />
    <tr align="center" valign="middle"> 
      <td align="left" id="upid" height="80" width="400"> 选择文件:<input type="file" name="file" />
      </br></br><font color="#FF0000">*注意：目前只支持 mp3|wma|rm|mp4 类型大小为10M以下的文件</font>
      </td>
    </tr>
    <tr align="center" valign="middle" bgcolor="#BBBBBB"> 
      <td bgcolor="#D6DFF7" height="24" width="400"> 
        <input type="submit" name="submit" value="· 开始上传 ·" class="button" onClick="javascript:mysub()">      </td>
    </tr>
  </table>
</form>
<?php
require_once("../../include/userset.php");
if ($_GET['ac']==go) {
$host = S_Ftp;
$user = S_Fuser;
$pass = S_Fpass;
$destDir = S_Fdir;
$workDir = "./"; 
$fname=$_FILES['file']['name'];
$sys=pathinfo($fname);//获取文件名后缀
$Panfname=$sys['extension'];
//判断是否是音乐文件
if($Panfname!="mp3" && $Panfname!="wma" && $Panfname!="rm" && $Panfname!="mp4"){exit("<script language=javascript>alert('对不起,请上传正确的音乐文件！');window.close()</script>");}
$tmpName = basename($_FILES['file']['tmp_name']);
move_uploaded_file($_FILES['file']['tmp_name'], $workDir."/".$tmpName) or die("Cannot move uploaded file to working directory");
$conn = ftp_connect($host) or die ("Cannot initiate connection to host");
ftp_login($conn, $user, $pass) or die("Cannot login");
$upload = ftp_put($conn, $destDir."/".$_FILES['file']['name'], $workDir."/".$tmpName, FTP_BINARY);
if (!$upload) {
    echo "<script language=javascript>alert('对不起,".$_FILES['file']['name']."上传失败！');window.close()</script>";
} else {
    echo "<script>window.opener.document.form3.S_Vdata.value='".$_FILES['file']['name']."'</script><script language=javascript>alert('恭喜您,上传成功！');window.close()</script>";
}
ftp_close($conn);
unlink($workDir."/".$tmpName) or die("Cannot delete uploaded file from working directory -- manual deletion recommended");
}
?>
</body>
</html>
