论坛首页 Web前端技术论坛

Uploadify上传文件并改名

浏览 3866 次
精华帖 (0) :: 良好帖 (0) :: 新手帖 (0) :: 隐藏帖 (0)
作者 正文
   发表时间:2012-03-01  
Uploadify上传插件,用自带的例子可以同时上传几个文件,我想改成用时间做文件名,只能上传一个,为什么?
if (!empty($_FILES)) {
	$tempFile = $_FILES['Filedata']['tmp_name'];
	$targetPath = $_SERVER['DOCUMENT_ROOT'] . $_REQUEST['folder'] . '/';
//下面是官方例子自带的
	$targetFile =  str_replace('//','/',$targetPath) . $_FILES['Filedata']['name'];
//这个是我要改成时间做文件名
	$targetFile =  str_replace('//','/',$targetPath) . date("YmdHis") . ".jpg";	
	
	// $fileTypes  = str_replace('*.','',$_REQUEST['fileext']);
	// $fileTypes  = str_replace(';','|',$fileTypes);
	// $typesArray = split('\|',$fileTypes);
	// $fileParts  = pathinfo($_FILES['Filedata']['name']);
	
	// if (in_array($fileParts['extension'],$typesArray)) {
		// Uncomment the following line if you want to make the directory if it doesn't exist
		// mkdir(str_replace('//','/',$targetPath), 0755, true);
		
		move_uploaded_file($tempFile,$targetFile);
		echo str_replace($_SERVER['DOCUMENT_ROOT'],'',$targetFile);
	// } else {
	// 	echo 'Invalid file type.';
	// }
}
   发表时间:2012-03-14  
自己解决了
0 请登录后投票
论坛首页 Web前端技术版

跳转论坛:
Global site tag (gtag.js) - Google Analytics