| 
       多文件上传是PHP中的一个基础应用,反正PHPer都会遇到的问题,现在就介绍一个功能完善、强大的多文件上传类给大家吧,能用上这个类的地方会很多,代码如下: 
	
	- <?php 
 
	- class Upload{ 
 
	-  var $saveName; 
 
	-  var $savePath; 
 
	-  var $fileFormat = array('gif','jpg','doc','application/octet-stream'); 
 
	-  var $overwrite = 0; 
 
	-  var $maxSize = 0; 
 
	-  var $ext; 
 
	-  var $thumb = 0; 
 
	-  var $thumbWidth = 130; 
 
	-  var $thumbHeight = 130; 
 
	-  var $thumbPrefix = "_thumb_"; 
 
	-  var $errno; 
 
	-  var $returnArray= array(); 
 
	-  var $returninfo= array(); 
 
	-  
 
	-  
 
	-  
 
	-  
 
	-  
 
	-  
 
	-  function Upload($savePath, $fileFormat='',$maxSize = 0, $overwrite = 0) { 
 
	-   $this->setSavepath($savePath); 
 
	-   $this->setFileformat($fileFormat); 
 
	-   $this->setMaxsize($maxSize); 
 
	-   $this->setOverwrite($overwrite); 
 
	-   $this->setThumb($this->thumb, $this->thumbWidth,$this->thumbHeight); 
 
	-   $this->errno = 0; 
 
	-  } 
 
	-  
 
	-  
 
	-  
 
	-  function run($fileInput,$changeName = 1){ 
 
	-   if(isset($_FILES[$fileInput])){ 
 
	-    $fileArr = $_FILES[$fileInput]; 
 
	-    if(is_array($fileArr['name'])){ 
 
	-     for($i = 0; $i < count($fileArr['name']); $i++){ 
 
	-      $ar['tmp_name'] = $fileArr['tmp_name'][$i]; 
 
	-      $ar['name'] = $fileArr['name'][$i]; 
 
	-      $ar['type'] = $fileArr['type'][$i]; 
 
	-      $ar['size'] = $fileArr['size'][$i]; 
 
	-      $ar['error'] = $fileArr['error'][$i]; 
 
	-      $this->getExt($ar['name']); 
 
	-      $this->setSavename($changeName == 1 ? '' : $ar['name']); 
 
	-      if($this->copyfile($ar)){ 
 
	-       $this->returnArray[] =  $this->returninfo; 
 
	-      }else{ 
 
	-       $this->returninfo['error'] = $this->errmsg(); 
 
	-       $this->returnArray[] =  $this->returninfo; 
 
	-      } 
 
	-     } 
 
	-     return $this->errno ?  false :  true; 
 
	-    }else{ 
 
	-     $this->getExt($fileArr['name']); 
 
	-     $this->setSavename($changeName == 1 ? '' : $fileArr['name']); 
 
	-     if($this->copyfile($fileArr)){ 
 
	-      $this->returnArray[] =  $this->returninfo; 
 
	-     }else{ 
 
	-      $this->returninfo['error'] = $this->errmsg(); 
 
	-      $this->returnArray[] =  $this->returninfo; 
 
	-     } 
 
	-     return $this->errno ?  false :  true; 
 
	-    } 
 
	-    return false; 
 
	-   }else{ 
 
	-    $this->errno = 10; 
 
	-    return false; 
 
	-   } 
 
	-  } 
 
	-  
 
	-  
 
	-  function copyfile($fileArray){ 
 
	-   $this->returninfo = array(); 
 
	-    
 
	-   $this->returninfo['name'] = $fileArray['name']; 
 
	-   $this->returninfo['md5'] = @md5_file($fileArray['tmp_name']); 
 
	-   $this->returninfo['saveName'] = $this->saveName; 
 
	-   $this->returninfo['size'] = number_format( ($fileArray['size'])/1024 , 0, '.', ' '); 
 
	-   $this->returninfo['type'] = $fileArray['type']; 
 
	-    
 
	-   if (!$this->validateFormat()){ 
 
	-    $this->errno = 11; 
 
	-    return false; 
 
	-   } 
 
	-    
 
	-   if(!@is_writable($this->savePath)){ 
 
	-    $this->errno = 12; 
 
	-    return false; 
 
	-   } 
 
	-    
 
	-    
 
	-    
 
	-    
 
	-   
    |