fileName = $ _FILES ['uploaded'] ['name'];
$ this-> tmpName = $ _FILES ['uploaded'] ['tmp_name'];
if(!$ this-> isWritable())
{
死(“抱歉,你必须将你的上传目标CHMOD到777!”);
}
if(!$ this-> checkExt())
{
死(“对不起,你不能上传这个文件类型!”);
}
if(!$ this-> checkSize())
{
死(“抱歉,你试图上传的文件太大了!”);
}
if($ this-> fileExists())
{
die(“抱歉,这个文件已存在于我们的服务器上!”);
}
if($ this-> uploadIt())
{
呼应“成功”;
echo“您的文件已上传!
点击uploadTarget.time()。$ this-> fileName。”\“>这里查看您的文件!”;
}
其他
{
echo“抱歉,由于某些未知原因,您的文件无法上传!”;
}
}
公共功能uploadIt()
{
return(move_uploaded_file($ this-> tmpName,$ this-> uploadTarget.time()。$ this-> fileName)?true:false);
}
公共函数checkSize()
{
return((filesize($ this-> tmpName)> $ this-> maxSize)?false:true);
}
公共函数getExt()
{
return strtolower(substr($ this-> fileName,strpos($ this-> fileName,“。”),strlen($ this-> fileName) - 1));
}
public function checkExt()
{
return(in_array($ this-> getExt(),$ this-> exts)?true:false);
}
公共函数isWritable()
{
return(is_writable($ this-> uploadTarget));
}
公共函数fileExists()
{
return(file_exists($ this-> uploadTarget.time()。$ this-> fileName));
}
}
$ img = new imgUploader();
?>