<?phpclass upload
{
function upload($uploadfile = "",$Sfolder = "")
{
@$files = $_FILES[$uploadfile];

$fileTmpName = $files["tmp_name"];
$file = $files["name"];
$fileType = $this -> _isType($file);
$fileEnd = $this -> GetUploadType($file);
$fileSize = $files["size"];
//echo $fileSize;
if(!$fileType){
return false;
}else{
$Sfolder = $this -> _createDir($Sfolder);
$file = date("Ymdhis",time()).rand(1,100).".".$fileEnd;
return move_uploaded_file($fileTmpName,$Sfolder.$file)?true:false;
}
} function GetUploadType($file)
{
return substr(strrchr($file,"."),1);
} function _isType($file)
{
$Farray = array("gif","jpg","bmp","flv","chm");
$filetype = $this -> GetUploadType($file);
return in_array($filetype,$Farray);
}
function _isSize($file,$length){
return $file < $length?true:false;
}
function _createDir($folder = "")
{
$root = "";
$pathSign = DIRECTORY_SEPARATOR;
$fileName = date("Ymd",time()).$pathSign;
$path = $root . $folder . "/".$fileName;
$dirArray = explode($pathSign,$path); $tempDir=""; foreach($dirArray as $dir)
{
$tempDir.= $dir.$pathSign; $isFile = file_exists( $tempDir );
clearstatcache();
if(!$isFile && !is_dir($tempDir))
{
@mkdir($tempDir,0777);
}
}
$filePath = $path . $pathSign;
return str_replace("\\","/",$path);
}}
?>在做 上传内容大小限制的时候/总是出问题?请问如何处理?