欢迎您访问程序员文章站本站旨在为大家提供分享程序员计算机编程知识!
您现在的位置是: 首页  >  后端开发

php 简单文件图片上传类_PHP教程

程序员文章站 2022-05-05 21:37:52
...
php 简单文件图片上传类

这个文件上传类可以上传gif",".jpg",".jar",".jad",".mid",".mp3",".mid",".bmp",".wav",".rm",".wmv文件格式哦,如果你还想支持其它的话可以设计$this->file_type();就OK了,。

class upload{

var $file_type;
var $file_size;
var $file_name;
var $exname;
var $datetime;


function up($post_name,$path){
$this->file_name=$_FILES[$post_name]["name"];
$this->exname=strtolower(substr($this->file_name,strrpos($this->file_name,".")));
$this->file_size=$_FILES[$post_name]["size"];
$this->file_type=array(".gif",".jpg",".jar",".jad",".mid",".mp3",".mid",".bmp",".wav",".rm",".wmv");
$this->datetime=date("YmdHis");
if(!in_array($this->exname,$this->file_type)){
print("");
break;
}elseif($this->file_size>"50000"){
print("");
break;
}else{
move_uploaded_file($_FILES[$post_name]["tmp_name"],$path.$this->datetime.$this->exname);
}
}

function fileName(){
$pic=$this->datetime.$this->exname;
return $pic;
}

}
?>


www.bkjia.comtruehttp://www.bkjia.com/PHPjc/445032.htmlTechArticlephp 简单文件图片上传类 这个文件上传类可以上传gif,.jpg,.jar,.jad,.mid,.mp3,.mid,.bmp,.wav,.rm,.wmv文件格式哦,如果你还想支持其它的话可以设计$...