up.class.php
<?php class up{ public $f;//= $_files[xx] public $s;//upload file size public $n;// Whether to specify a filename public $d; Specify folder 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 (); } &N bsp; Function fname () { if ($this->n) {return $this->n. $this->ftype ();} else{return Time (). Rand (111,999). $this->ftype ();} } function Fdir () { if ($this-> D) { //Determines whether the user specifies the folder name if (!is_dir ($this->d)) {//Determines whether the specified folder name exists mkdir ($this->d);} return $this->d. " /"; }else{ if (!is_dir ("YMD")) {mkdir (date ("YMD"))} return date ("Ymd"). " /"; &NBSP} }//end fdir function fsize () { if ($this->f[' size ']> $this->s){echo "file exceeds size"; 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 "Incorrect file type"; exit ();} } function FMV () { &NBSP;MOVE_UP Loaded_file ($this->f[' tmp_name '), $this->fdir (). $this->fname ()); &NBSP} } ?> test.php upload file <?php include ("up.class.php"); if (!empty ($_post[' Sub ')) { foreach ($_files as $id => $v) { New up ($_files[$id]); } } &nb SP;? > <form action= "" method= "Post" enctype= "Multipart/form-data" > <input type= "file" Name= "P1" ><br> <input type= "FIle "Name=" P2 "><br> <input type=" file "name=" P3 "><br> <input type=" file "Name=" P4 "><br > <input type= "File" Name= "P5" ><br> <input type= "file" Name= "P6" ><br> <input type= " Submit "Name=" sub "value=" Upload "> </form>