Home > Backend Development > PHP Tutorial > PHP simple file and image upload class_PHP tutorial

PHP simple file and image upload class_PHP tutorial

WBOY
Release: 2016-07-20 11:06:22
Original
985 people have browsed it

PHP simple file and image upload class

This file upload class can upload gif",".jpg",".jar",".jad",".mid",".mp3",".mid",". bmp", ".wav", ".rm", ".wmv file formats. If you want to support other file formats, you can design $this->file_type(); and it will be 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 Simple file and image upload class This file upload class can upload gif,.jpg,.jar,.jad,. mid, .mp3, .mid, .bmp, .wav, .rm, .wmv file formats, if you want to support other ones, you can design $...
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template