这篇文章将为大家详细讲解有关PHP中怎么利用上传类实现单个和批量上传,文章内容质量较高,因此小编分享给大家做个参考,希望大家阅读完这篇文章后对相关知识有一定的了解。php上传类代码:<?php cla
这篇文章将为大家详细讲解有关PHP中怎么利用上传类实现单个和批量上传,文章内容质量较高,因此小编分享给大家做个参考,希望大家阅读完这篇文章后对相关知识有一定的了解。
php上传类代码:
<?php claSSMyFrame_UploadextendsmyFrame { var$uploadPath="uploadFile/"; var$fullPath=''; var$message; var$_debug=false; var$errORMessage=''; function__construct($uploadPath='') { if($uploadPath!="") { $this->uploadPath=$uploadPath; } } publicfunctionformLocalBatch($keepSource=false,$arrayOutPut='') { $returnArray=array(); if(sizeof($_FILES)==$arrayOutPut&&!$keepSource) { $i=0; foreach($_FILESas$index=>$value) { $returnArray[]=$this->fromLocal($value,$outPutName[$i]); $i++; } }else{ foreach($_FILESas$index=>$value) { $returnArray[]=$this->fromLocal($value); } } return$returnArray; } publicfunctionfromLocal($VALUE,$outPutName='') { include_once(SERVERROOT.MYFRAME.'myFrame_Basic.php'); if($outPutName==''||$outPutName=="NULL") { $outPutName=date("YmdHis"); } if($VALUE['error']>0) { switch($VALUE['errror']) { case'1': $this->errorMessage[]=$this->myFrameMessage['false']['file']['max']; returnfalse; break; case'2': $this->errorMessage[]=$this->myFrameMessage['false']['file']['maxDefined']; returnfalse; break; case'3': $this->errorMessage[]=$this->myFrameMessage['false']['file']['uncomplite']; returnfalse; break; case'4': $this->errorMessage[]=$this->myFrameMessage['false']['file']['unupload']; returnfalse; break; } } $fileName=$this->uploadPath.$outPutName.myFrame_Basic::getFileName($VALUE['name']).myFrame_Basic::getFileExt($VALUE['name']); if(is_uploaded_file($VALUE['tmp_name'])) { if(!move_uploaded_file($VALUE['tmp_name'],$fileName)) { $this->errorMessage[]=$this->myFrameMessage['false']['file']['move']; returnfalse; }else{ return$fileName; } } } publicfunctionfromNet($url,$outPutName='',$keepSource=false) { include_once(SERVERROOT.MYFRAME.'myFrame_Basic.php'); if($outPutName=="") { $outPutName=date("YmdHis"); } $fileType=myFrame_Basic::getFileExt($url); $fileName=$outPutName.$fileType; $contents=file_get_contents($url); $return=file_put_contents($this->uploadPath.$fileName,$contents); if($return){ $this->fullPath=$this->uploadPath.$fileName; return$this->fullPath; }else{ $this->errorMessage[]=$this->myFrameMessage['false']['file']['url']; returnfalse; } } }
关于PHP中怎么利用上传类实现单个和批量上传就分享到这里了,希望以上内容可以对大家有一定的帮助,可以学到更多知识。如果觉得文章不错,可以把它分享出去让更多的人看到。
--结束END--
本文标题: PHP中怎么利用上传类实现单个和批量上传
本文链接: https://www.lsjlt.com/news/292524.html(转载时请注明来源链接)
有问题或投稿请发送至: 邮箱/279061341@qq.com QQ/279061341
下载Word文档到电脑,方便收藏和打印~
2024-02-29
2024-02-29
2024-02-29
2024-02-29
2024-02-29
2024-02-29
2024-02-29
2024-02-29
2024-02-29
2024-02-29
回答
回答
回答
回答
回答
回答
回答
回答
回答
回答
0