<?php
@set_time_limit(0);
if(!isset($_COOKIE["cs_name"]) && !isset($_COOKIE['CS_AdminUP'])){
	exit('非法操作！');
}
if (!empty($_FILES)) {
	$tempFile = $_FILES['Filedata']['tmp_name'];
	$targetPath = $_SERVER['DOCUMENT_ROOT'] . $_REQUEST['folder'] . '/'.date('Ym').'/';
	$file_name = $_FILES['Filedata']['name'];
	
	//获得文件扩展名
	$temp_arr = explode(".", $file_name);
	$file_ext = array_pop($temp_arr);
	$file_ext = trim($file_ext);
	$file_ext = strtolower($file_ext);

        if($file_ext=='mp3' || $file_ext=='wma' || $file_ext=='mp4' || $file_ext=='flv'){  //判断后缀
        }else{
                @unlink($tempFile);
        }

	//新文件名
	$new_file_name = date("YmdHis") . '_' . rand(10000, 99999) . '.' . $file_ext;

	$targetFile =  str_replace('//','/',$targetPath) . $new_file_name;
	
	!is_dir(str_replace('//','/',$targetPath)) && mkdir(str_replace('//','/',$targetPath), 0755, true);
		
        if(substr($targetFile,-3)=='mp3' || substr($targetFile,-3)=='wma' || substr($targetFile,-3)=='mp4' || substr($targetFile,-3)=='flv'){  //判断后缀
		@move_uploaded_file($tempFile,$targetFile);
		echo $_REQUEST['folder'].'/'.date('Ym').'/'.$new_file_name;
        }else{
		@unlink($tempFile);
                echo 'no';
        }	
	
}
?>
