up.class.php
class up{
public $f; //表示$_FILES[xx]
public $s; //上传文件的大小
public $n; //是否指定文件名
public $d; //是否指定文件夹
function __construct($f,$s=1,$n=false,$d=false){
$this->f=$f;
$this->s=$s*1000000;
$this->n=$n;
$this->d=$d;
$this->loading();
}
function loading(){
$this->fsize();
$this->ftype();
$this->fmv();
}
function fname(){
if($this->n){
return $this->n.$this->ftype();
}else{
return time().rand(111,999).$this->ftype();
}
}
function fdir(){
if($this->d){ //判断用户是否指定文件夹名
if(!is_dir($this->d)){ //判断指定的文件夹名是否存在
mkdir($this->d);
}
return $this->d."/";
}else{
if(!is_dir(date("Ymd"))){
mkdir(date("Ymd"));
}
return date("Ymd")."/";
}
} //end fdir
function fsize(){
if($this->f['size']>$this->s){
echo "文件超过大小";
exit();
}else{
return true;
}
}
function ftype(){
switch($this->f['type']){
case "image/x-png": $ok=".png";
break;
case "image/png": $ok=".png";
break;
case "application/pdf": $ok=".pdf";
break;
case "image/pjpeg": $ok=".jpg";
break;
case "image/jpeg": $ok=".jpg";
break;
case "image/jpg": $ok=".jpg";
break;
default: $ok=false;
break;
}
if($ok){
return $ok;
}else{
echo "文件类型不正确";
exit();
}
}
function fmv(){
move_uploaded_file($this->f['tmp_name'],$this->fdir().$this->fname());
}
}
?>
test.php 上传文件
include("up.class.php");
if(!empty($_POST['sub'])){
foreach($_FILES as $id=>$v){
new up($_FILES[$id]);
}
}
?>

热AI工具

Undresser.AI Undress
人工智能驱动的应用程序,用于创建逼真的裸体照片

AI Clothes Remover
用于从照片中去除衣服的在线人工智能工具。

Undress AI Tool
免费脱衣服图片

Clothoff.io
AI脱衣机

Video Face Swap
使用我们完全免费的人工智能换脸工具轻松在任何视频中换脸!

热门文章

热工具

SecLists
SecLists是最终安全测试人员的伙伴。它是一个包含各种类型列表的集合,这些列表在安全评估过程中经常使用,都在一个地方。SecLists通过方便地提供安全测试人员可能需要的所有列表,帮助提高安全测试的效率和生产力。列表类型包括用户名、密码、URL、模糊测试有效载荷、敏感数据模式、Web shell等等。测试人员只需将此存储库拉到新的测试机上,他就可以访问到所需的每种类型的列表。

SublimeText3 英文版
推荐:为Win版本,支持代码提示!

安全考试浏览器
Safe Exam Browser是一个安全的浏览器环境,用于安全地进行在线考试。该软件将任何计算机变成一个安全的工作站。它控制对任何实用工具的访问,并防止学生使用未经授权的资源。

Dreamweaver CS6
视觉化网页开发工具

Atom编辑器mac版下载
最流行的的开源编辑器