自拍偷在线精品自拍偷,亚洲欧美中文日韩v在线观看不卡

PHP上傳類實(shí)現(xiàn)單個(gè)和批量上傳

開發(fā) 后端
PHP語言擁有強(qiáng)大的功能,受到了大部分人的喜愛,文章這里有PHP上傳類的詳細(xì)代碼,希望對(duì)大家有幫助。

PHP上傳類還是比較常用的,于是我研究了一下PHP上傳類,在這里拿出來和大家分享一下,希望對(duì)大家有用。PHP本身是一種簡(jiǎn)單而強(qiáng)大的語言。PHP語言擁有核心特性如強(qiáng)大的字符串和數(shù)組處理能力,同時(shí)極大的改進(jìn)了對(duì)面向?qū)ο缶幊痰闹С郑≒HP5以上版本)。

#T#通過使用標(biāo)準(zhǔn)的和可選的擴(kuò)展模塊,PHP應(yīng)用程序可以連接MySQL或Oracle等十幾種數(shù)據(jù)庫、繪圖、創(chuàng)建PDF文件和創(chuàng)建解析XML文件。你也可以使用C語言來寫自己的PHP擴(kuò)展模塊。例如,在已存在的代碼庫中提供一個(gè)PHP的接口函數(shù)。你也可以在Windows下運(yùn)行PHP,使用COM控制其它諸如Word和Excel的Windows應(yīng)用程序,或者使用ODBC來連接數(shù)據(jù)庫。在國(guó)內(nèi),PHP曾經(jīng)和微軟的ASP并駕齊驅(qū),是大家常用的網(wǎng)絡(luò)編程語言?!?/P>

PHP上傳類代碼:

  1. <?php 
  2. /**  
  3. *@packagemyFrameworkuploadclass  
  4. *@Descriptionuploadclass  
  5. *@Date2007-11-28  
  6. *@authorantsnet  
  7. *@copyrighthttp://www.antsnet.net  
  8. *@Emailantsnet@163.com  
  9. *@Environment:Apache2.0.59+PHP5.2.5+mysql5.0  
  10. *@version$Id:myFrame_Upload.php22008-02-2701:14:05ZAdministrator$  
  11. */  
  12. classmyFrame_UploadextendsmyFrame  
  13. {  
  14. var$uploadPath="uploadFile/";  
  15. var$fullPath='';  
  16. var$message;  
  17. var$_debug=false;  
  18. var$errorMessage='';  
  19.  
  20. function__construct($uploadPath='')  
  21. {  
  22. if($uploadPath!="")  
  23. {  
  24. $this->uploadPath=$uploadPath;  
  25. }  
  26. }  
  27. /**  
  28. *Batchupload  
  29. *  
  30. *@paramArray$arrayOutPut  
  31. */  
  32. publicfunctionformLocalBatch($keepSource=false,$arrayOutPut='')  
  33. {  
  34. $returnArray=array();  
  35. if(sizeof($_FILES)==$arrayOutPut&&!$keepSource)  
  36. {  
  37. $i=0;  
  38. foreach($_FILESas$index=>$value)  
  39. {  
  40. $returnArray[]=$this->fromLocal($value,$outPutName[$i]);  
  41. $i++;  
  42. }  
  43. }else{  
  44. foreach($_FILESas$index=>$value)  
  45. {  
  46. $returnArray[]=$this->fromLocal($value);  
  47. }  
  48. }  
  49. return$returnArray;  
  50. }  
  51. /**  
  52. *Uploadfileformlocal  
  53. *  
  54. *@paramArray|String$file_Area_Name  
  55. *@paramArray|String$outPutName  
  56. */  
  57. publicfunctionfromLocal($VALUE,$outPutName='')  
  58. {  
  59.  
  60. include_once(SERVERROOT.MYFRAME.'myFrame_Basic.php');  
  61. /**  
  62. *thefollowingforsingle  
  63. */  
  64. if($outPutName==''||$outPutName=="NULL")  
  65. {  
  66. $outPutName=date("YmdHis");  
  67. }  
  68. if($VALUE['error']>0)  
  69. {  
  70. switch($VALUE['errror'])  
  71. {  
  72. case'1':  
  73. $this->errorMessage[]=$this->myFrameMessage['false']['file']['max'];  
  74. returnfalse;  
  75. break;  
  76. case'2':  
  77. $this->errorMessage[]=$this->myFrameMessage['false']['file']['maxDefined'];  
  78. returnfalse;  
  79. break;  
  80. case'3':  
  81. $this->errorMessage[]=$this->myFrameMessage['false']['file']['uncomplite'];  
  82. returnfalse;  
  83. break;  
  84. case'4':  
  85. $this->errorMessage[]=$this->myFrameMessage['false']['file']['unupload'];  
  86. returnfalse;  
  87. break;  
  88.  
  89. }  
  90. }  
  91. $fileName=$this->uploadPath.$outPutName.myFrame_Basic::getFileName($VALUE['name']).myFrame_Basic::getFileExt($VALUE['name']);  
  92. if(is_uploaded_file($VALUE['tmp_name']))  
  93. {  
  94. if(!move_uploaded_file($VALUE['tmp_name'],$fileName))  
  95. {  
  96. $this->errorMessage[]=$this->myFrameMessage['false']['file']['move'];  
  97. returnfalse;  
  98. }else{  
  99. return$fileName;  
  100. }  
  101. }  
  102. }  
  103. /**  
  104. *Uploadfromnetwork  
  105. *  
  106. *@paramArray|String$url  
  107. *@paramArray|String$outPutName  
  108. *@paramBool$keepSource  
  109. */  
  110. publicfunctionfromNet($url,$outPutName='',$keepSource=false)  
  111. {  
  112. include_once(SERVERROOT.MYFRAME.'myFrame_Basic.php');  
  113. if($outPutName=="")  
  114. {  
  115. $outPutName=date("YmdHis");  
  116. }  
  117. $fileType=myFrame_Basic::getFileExt($url);  
  118. $fileName=$outPutName.$fileType;  
  119. $contents=file_get_contents($url);  
  120. $return=file_put_contents($this->uploadPath.$fileName,$contents);  
  121. if($return){  
  122. $this->fullPath=$this->uploadPath.$fileName;  
  123. return$this->fullPath;  
  124. }else{  
  125. $this->errorMessage[]=$this->myFrameMessage['false']['file']['url'];  
  126. returnfalse;  
  127. }  
  128. }  

 

責(zé)任編輯:田樹 來源: 博客
相關(guān)推薦

2009-11-24 14:45:08

PHP批量上傳圖片

2009-11-16 09:53:56

PHP上傳類

2009-11-16 10:40:02

PHP上傳文件代碼

2009-11-24 15:01:59

PHP通用文件上傳類

2009-11-16 10:25:40

PHP上傳文件

2009-11-24 13:15:35

Zend框架PHP上傳文件

2009-11-24 15:50:09

PHP上傳類uploa

2009-11-16 12:17:46

PHP上傳文件類型

2009-05-18 10:23:43

文件上傳PHPFILE函數(shù)

2009-11-16 14:15:51

PHP上傳多個(gè)文件

2009-11-16 10:16:24

PHP文件上傳

2009-11-24 16:09:44

PHP Ajax

2009-11-24 15:23:50

PHP文件上傳進(jìn)度條

2009-11-16 13:04:04

PHP上傳文件代碼

2009-06-26 13:46:13

Struts

2009-11-16 13:27:20

PHP上傳多張圖片

2009-11-16 09:35:42

PHP上傳

2009-11-16 11:41:19

PHP上傳大文件

2009-11-16 10:49:43

PHP上傳文件代碼

2009-11-30 19:09:46

PHP上傳圖片
點(diǎn)贊
收藏

51CTO技術(shù)棧公眾號(hào)