This is a super simple upload Class I wrote last night, as long as $up->upload ($_files[' imgfile '); Can. A statement to get the upload Shijiazhuang industry and commerce agent to all grassroots personal webmaster upload files: up.php<?php//Verify if (Empty ($_cookie[' login ')) {die (' index ');} Load Class include_once ("_inc/class_uppic.php");//Upload if (!empty ($_get[' action ')) && $_get[' action '] = = "Upload") {$ Up->upload ($_files[' imgfile '); echo "uploaded successfully! File name: {$up->new_url} <a href=?yes> re-upload </a> ";}?><formAction= "? Action=upload"Method= "POST"enctype= "Multipart/form-data">Photo Source:<inputtype= "File"name= "Imgfile"style= "width:200px;height:25px;"><inputtype= "Submit"name= "Submit"value= "Upload"style= "width:50px;height:25px;">//================ Split Line ============== class file: class_uppic.php<?php/* power by jtxxol.com 2011-06-20*/$up =new class_uppic;class class_uppic{function __constr UCT () {//Save directory $this->save_path= '/uploadfile/'; File links $this->save_url= '/uploadfile/'; Allowable size 300k $this->allow_size=300000; Allowable type $this->allow_ext= ' jpg,jpeg,gif,png '; The new file name $this->new_name=date ("Ymdhis"). Rand (10,99); Initialization error prompt $this->err= '; }//Upload function upload ($arr) {$this->file= $arr; Initialize Settings $this->allow_ext=explode (', ', $this->allow_ext); $this->save_path=$_server[' Document_root '). $this->save_path.date (' y-m '). ' /‘; $this->save_url= $this->save_url.date (' y-m '). /‘; Get extension $temp _arr = explode (".", $this->file[' name ')); $file _ext = Array_pop ($temp _arr); $file _ext = Trim (Strtolower ($file _ext)); Check type if (!in_array ($file _ext, $this->allow_ext)) {$this->err= "upload picture type wrong Error "; }//Check size if ($this->file[' size ']> $this->allow_size) { $this->err= "file exceeds the limit size"; }//recursively set up directory $this->creatdir ($this->save_path); The uploaded path $this->new_path= $this->save_path. $this->new_name. $file _ext; $this->new_url = $this->save_url. $this->new_name. '. ' $file _ext; Check for errors if (!empty ($this->err)) {$this->show ($this->err); }//Upload if (!move_uploaded_file ($this->file[' tmp_name '), $this->new_path)) { $thiS->err= "Error uploading file"; $this->show ($this->err); }}//Establish directory function Creatdir ($Dir) {if (Is_dir ($Dir)) r Eturn true; if (@ mkdir ($Dir, 0777)) return true; if (! $this->creatdir (dirname ($Dir))) return false; return mkdir ($Dir, 0777); }//error message function Show ($ERRORSTR) {echo "<script language=javascript> Alert (' $errorstr '); location= ' Javascript:history.go (-1); '; </script> "; Exit (); } }?>