Home > Backend Development > PHP Tutorial > php下传文件类

php下传文件类

WBOY
Release: 2016-06-13 11:03:42
Original
935 people have browsed it

php上传文件类

<?phpheader ("Content-Type:text/html; charset=utf-8;");echo "uploadclass<br/>";echo "<br>".$_FILES['file']["name"]."<br>";$nabc = new uploadclass($_FILES['file']); echo "<br>".$nabc->getname()."<br>";//获取新的名字class uploadclass {	var $location ;//设置存放文件的目录	var $max_size;//上传文件的大小	var $event; //初始值是success	var $filename;//获取保存在文件夹里的文件的文件名字	function uploadclass($file) {		$location = "./temp/";//设置存放文件的目录		$max_size = 1000000;//上传文件的大小		$event="success"; //初始值是success		//判断目录是否存在		if(! is_dir($location))		 { 			  mkdir($location);			  @chmod($location,777);		 }		 		$oldFilename = $file["name"];		$filename = explode(".",$oldFilename);		$filenameext = $filename[count($filename) - 1];		$newFilename = "_".time()."_".rand(10000, 20000).".".$filenameext;		$this->filename = $newFilename;				echo "<br>".$this->$filename."<br>";		if(!$file['name']=="")		{ 			if($file['size']filename;	  }}?>
Copy after login


1楼baiducheng2012-12-13 17:02
真的第一次见到
Related labels:
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