/* written by LiYongQuan */
function
up_file($UploadFile,$UploadPath,$FName,$UploadFile_size,$isover=0,$TimeLimit=60)
{
// $UploadFile: source file
// $UploadPath: destination path
// $FName: destination file
// $UploadFile_size: source file size
// $isover: if destination is aleady exist, overwrite? 0-No;1-Yes
//$TimeLimit: set_time_limit=?
//example:up_file($UploadFile,$dis,$UploadFile_name,$UploadFile_size,0,60);
set_time_limit($TimeLimit);
$FileName = AddSlashes($UploadPath).$FName;
if(($UploadFile =="none") || ($UploadFile == ""))
{echo("You didn't choice any file!");
return(1);
}
if(($FileName =="none") || ($FileName == ""))
{echo("You didn't supply destination file!");
return(2);
}
$FileName = AddSlashes($UploadPath).$FName;
if($UploadFile_size<1024)
{$FileSize=(string)$UploadFile_size."byte";}
elseif($UploadFile_size<(1024*1024))
{$FileSize=number_format((double)($UploadFile_size/1024),1)."KB";}
else
{$FileSize=number_format((double)($UploadFile_size/(1024*1024)),1)."MB";}
if(!file_exists($FileName) || $isover)
{if(copy($UploadFile,$FileName))
{echo("File1: $FName($FileSize) upload successful!");
return(0);
}
else
{echo("File: $FName($FileSize) upload failed!");
return(3);
}
}
else
if(file_exists($FileName))
{echo("File: $FName already exist!");
return(3);
}
unlink($UploadFile);
set_time_limit(30);
}
?>
阅读(1295) | 评论(0) | 转发(0) |