php教程 php手册 完整代码演示PHP上传多个文件

完整代码演示PHP上传多个文件

Jun 13, 2016 am 11:04 AM
php 한 번 업로드 소개하다 암호 ~에 대한 다수의 전체 문서 데모

前几天看了一本关于PHP的书,让我感触很深,我先介绍一下PHP的发展史,然后在教大家一个PHP上传多个文件的一个小技巧。让我们先来简单的介绍一下PHP吧!PHP 最初是1994年Rasmus Lerdorf创建的,刚刚开始只是一个简单的用Perl语言编写的程序,用来统计他自己网站的访问者。后来又用C语言重新编写,包括可以访问数据库。

以后越来越多的网站使用了PHP,并且强烈要求增加一些特性,比如循环语句和数组变量等等,在新的成员加入开发行列之后,在1995年 中,PHP2.0发布了。第二版定名为PHP/FI(Form Interpreter)。PHP/FI加入了对mSQL的支持,从此建立了PHP在动态网页开发上的地位。到了1996年底,有15000个网站使用 PHP/FI;时间到了1997年中,使用PHP/FI的网站数字超过五万个。而在1997年中,开始了第三版的开发计划,开发小组加入了 Zeev Suraski 及 Andi Gutmans,而第三版就定名为PHP3。2000年,PHP4.0又问世了,其中增加了许多新的特性。以下给大家介绍一个PHP上传多个文件的方法。

PHP上传多个文件代码实现:

<ol class="dp-xml">
<li class="alt"><span><strong><font color="#006699"><span class="tag"></span><span class="tag-name">php</span></font></strong><span> </span></span></li>
<li class=""><span>require_once("include/upload.class.php");  </span></li>
<li class="alt"><span>if($_POST["button"])  </span></li>
<li class=""><span>{  </span></li>
<li class="alt"><span>//print_r($_FILES);  </span></li>
<li class=""><span>//多个上传  </span></li>
<li class="alt">
<span>//$</span><span class="attribute"><font color="#ff0000">upload</font></span><span>=</span><span class="attribute-value"><font color="#0000ff">newTTRUpload</font></span><span>($_FILES,"ANY");//同下  </span>
</li>
<li class=""><span> </span></li>
<li class="alt">
<span>$</span><span class="attribute"><font color="#ff0000">upload</font></span><span>=</span><span class="attribute-value"><font color="#0000ff">newTTRUpload</font></span><span>(array($_FILES["file1"],$_FILES["file2"],$_FILES["file3"],$_FILES["file4"]),"ANY");  </span>
</li>
<li class=""><span> </span></li>
<li class="alt"><span>//单个上传  </span></li>
<li class="">
<span>//$</span><span class="attribute"><font color="#ff0000">upload</font></span><span>=</span><span class="attribute-value"><font color="#0000ff">newTTRUpload</font></span><span>($_FILES["file1"]);  </span>
</li>
<li class="alt">
<span>$upload-</span><span class="tag"><strong><font color="#006699">></font></strong></span><span>upload();  </span>
</li>
<li class="">
<span>echo$upload-</span><span class="tag"><strong><font color="#006699">></font></strong></span><span>getUploadFileName();  </span>
</li>
<li class="alt"><span>}  </span></li>
<li class="">
<span></span><span class="tag"><strong><font color="#006699">?></font></strong></span><span> </span>
</li>
<li class="alt">
<span>-//W3C//DTDXHTML1.0Transitional//EN""http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"</span><span class="tag"><strong><font color="#006699">></font></strong></span><span> </span>
</li>
<li class="">
<span></span><span class="tag"><strong><font color="#006699"></font></strong></span><span class="attribute"><font color="#ff0000">htmlxmlns</font></span><span class="tag-name"><strong><font color="#006699">htmlxmlns</font></strong></span><span>=</span><span class="attribute-value"><font color="#0000ff">"http://www.w3.org/1999/xhtml"</font></span><span class="tag"><strong><font color="#006699">></font></strong></span><span> </span>
</li>
<li class="alt">
<span></span><strong><font color="#006699"><span class="tag"><span class="tag-name">head</span><span class="tag">></span></span></font></strong><span> </span>
</li>
<li class="">
<span></span><span class="tag"><strong><font color="#006699"></font></strong></span><span class="attribute"><font color="#ff0000">metahttp-equiv</font></span><span class="tag-name"><strong><font color="#006699">metahttp-equiv</font></strong></span><span>="Content-Type"</span><span class="attribute-value"><font color="#0000ff">content</font></span><span>="text/html;</span><span class="attribute"><font color="#ff0000">charset</font></span><span>=</span><span class="attribute-value"><font color="#0000ff">utf</font></span><span>-8"</span><span class="tag"><strong><font color="#006699">/></font></strong></span><span> </span>
</li>
<li class="alt">
<span></span><strong><font color="#006699"><span class="tag"><span class="tag-name">title</span><span class="tag">></span></span></font></strong><span>UntitledDocument</span><strong><font color="#006699"><span class="tag"></span><span class="tag-name">title</span><span class="tag">></span></font></strong><span> </span>
</li>
<li class="">
<span></span><strong><font color="#006699"><span class="tag"></span><span class="tag-name">head</span><span class="tag">></span></font></strong><span> </span>
</li>
<li class="alt"><span> </span></li>
<li class="">
<span></span><strong><font color="#006699"><span class="tag"><span class="tag-name">body</span><span class="tag">></span></span></font></strong><span> </span>
</li>
<li class="alt">
<span></span><span class="tag"><strong><font color="#006699"></font></strong></span><span class="attribute"><font color="#ff0000">formaction</font></span><span class="tag-name"><strong><font color="#006699">formaction</font></strong></span><span>=""</span><span class="attribute-value"><font color="#0000ff">method</font></span><span>="post"</span><span class="attribute"><font color="#ff0000">enctype</font></span><span>="multipart/form-data"</span><span class="attribute-value"><font color="#0000ff">name</font></span><span>="form1"</span><span class="attribute"><font color="#ff0000">id</font></span><span>=</span><span class="attribute-value"><font color="#0000ff">"form1"</font></span><span class="tag"><strong><font color="#006699">></font></strong></span><span> </span>
</li>
<li class="">
<span></span><span class="tag"><strong><font color="#006699"></font></strong></span><span class="attribute"><font color="#ff0000">inputtype</font></span><span class="tag-name"><strong><font color="#006699">inputtype</font></strong></span><span>="file"</span><span class="attribute-value"><font color="#0000ff">name</font></span><span>="file1"</span><span class="attribute"><font color="#ff0000">id</font></span><span>=</span><span class="attribute-value"><font color="#0000ff">"file1"</font></span><span class="tag"><strong><font color="#006699">/></font></strong></span><span> </span>
</li>
<li class="alt">
<span></span><strong><font color="#006699"><span class="tag"><span class="tag-name">br</span><span class="tag">/></span></span></font></strong><span> </span>
</li>
<li class="">
<span></span><span class="tag"><strong><font color="#006699"></font></strong></span><span class="attribute"><font color="#ff0000">inputtype</font></span><span class="tag-name"><strong><font color="#006699">inputtype</font></strong></span><span>="file"</span><span class="attribute-value"><font color="#0000ff">name</font></span><span>="file2"</span><span class="attribute"><font color="#ff0000">id</font></span><span>=</span><span class="attribute-value"><font color="#0000ff">"file2"</font></span><span class="tag"><strong><font color="#006699">/></font></strong></span><span> </span>
</li>
<li class="alt">
<span></span><strong><font color="#006699"><span class="tag"><span class="tag-name">br</span><span class="tag">/></span></span></font></strong><span> </span>
</li>
<li class="">
<span></span><span class="tag"><strong><font color="#006699"></font></strong></span><span class="attribute"><font color="#ff0000">inputtype</font></span><span class="tag-name"><strong><font color="#006699">inputtype</font></strong></span><span>="file"</span><span class="attribute-value"><font color="#0000ff">name</font></span><span>="file3"</span><span class="attribute"><font color="#ff0000">id</font></span><span>=</span><span class="attribute-value"><font color="#0000ff">"file3"</font></span><span class="tag"><strong><font color="#006699">/></font></strong></span><span> </span>
</li>
<li class="alt">
<span></span><strong><font color="#006699"><span class="tag"><span class="tag-name">br</span><span class="tag">/></span></span></font></strong><span> </span>
</li>
<li class="">
<span></span><span class="tag"><strong><font color="#006699"></font></strong></span><span class="attribute"><font color="#ff0000">inputtype</font></span><span class="tag-name"><strong><font color="#006699">inputtype</font></strong></span><span>="file"</span><span class="attribute-value"><font color="#0000ff">name</font></span><span>="file4"</span><span class="attribute"><font color="#ff0000">id</font></span><span>=</span><span class="attribute-value"><font color="#0000ff">"file4"</font></span><span class="tag"><strong><font color="#006699">/></font></strong></span><span> </span>
</li>
<li class="alt">
<span></span><strong><font color="#006699"><span class="tag"><span class="tag-name">br</span><span class="tag">/></span></span></font></strong><span> </span>
</li>
<li class="">
<span></span><span class="tag"><strong><font color="#006699"></font></strong></span><span class="attribute"><font color="#ff0000">inputtype</font></span><span class="tag-name"><strong><font color="#006699">inputtype</font></strong></span><span>="submit"</span><span class="attribute-value"><font color="#0000ff">name</font></span><span>="button"</span><span class="attribute"><font color="#ff0000">id</font></span><span>="button"</span><span class="attribute-value"><font color="#0000ff">value</font></span><span>="Submit"</span><span class="tag"><strong><font color="#006699">/></font></strong></span><span> </span>
</li>
<li class="alt">
<span></span><strong><font color="#006699"><span class="tag"></span><span class="tag-name">form</span><span class="tag">></span></font></strong><span> </span>
</li>
<li class="">
<span></span><strong><font color="#006699"><span class="tag"></span><span class="tag-name">body</span><span class="tag">></span></font></strong><span> </span>
</li>
<li class="alt">
<span></span><strong><font color="#006699"><span class="tag"></span><span class="tag-name">html</span><span class="tag">></span></font></strong><span> </span>
</li>
<li class=""><span> </span></li>
<li class="alt">
<span></span><strong><font color="#006699"><span class="tag"></span><span class="tag-name">php</span></font></strong><span> </span>
</li>
<li class=""><span>classTTRUploadextendsError  </span></li>
<li class="alt"><span>{  </span></li>
<li class="">
<span></span><span class="attribute"><font color="#ff0000">constfilesize</font></span><span>=</span><span class="attribute-value"><font color="#0000ff">81200000</font></span><span>;  </span>
</li>
<li class="alt">
<span>private$</span><span class="attribute"><font color="#ff0000">uploadpath</font></span><span>=</span><span class="attribute-value"><font color="#0000ff">"uploadfile/"</font></span><span>;  </span>
</li>
<li class="">
<span>private$</span><span class="attribute"><font color="#ff0000">savepath</font></span><span>=</span><span class="attribute-value"><font color="#0000ff">null</font></span><span>;  </span>
</li>
<li class="alt">
<span>private$</span><span class="attribute"><font color="#ff0000">uploadfilename</font></span><span>=</span><span class="attribute-value"><font color="#0000ff">null</font></span><span>;//单个文件为文件名,批量文件为xxxx|xxxx格式,请注意  </span>
</li>
<li class="">
<span>private$</span><span class="attribute"><font color="#ff0000">ext</font></span><span>=</span><span class="attribute-value"><font color="#0000ff">array</font></span><span>("jpg","gif","png");  </span>
</li>
<li class="alt">
<span>private$</span><span class="attribute"><font color="#ff0000">error</font></span><span>=</span><span class="attribute-value"><font color="#0000ff">null</font></span><span>;  </span>
</li>
<li class="">
<span>private$</span><span class="attribute"><font color="#ff0000">file</font></span><span>=</span><span class="attribute-value"><font color="#0000ff">null</font></span><span>;  </span>
</li>
<li class="alt">
<span>private$</span><span class="attribute"><font color="#ff0000">uploadtype</font></span><span>=</span><span class="attribute-value"><font color="#0000ff">null</font></span><span>;  </span>
</li>
<li class="">
<span>private$</span><span class="attribute"><font color="#ff0000">filename</font></span><span>=</span><span class="attribute-value"><font color="#0000ff">null</font></span><span>;  </span>
</li>
<li class="alt"><span> </span></li>
<li class=""><span>//构造函数,$type:ONE单个上传ANY批量上传;  </span></li>
<li class="alt">
<span>publicfunction__construct($file,$</span><span class="attribute"><font color="#ff0000">type</font></span><span>=</span><span class="attribute-value"><font color="#0000ff">"ONE"</font></span><span>)  </span>
</li>
<li class=""><span>{  </span></li>
<li class="alt"><span>if($type!="ONE"&&$type!="ANY")  </span></li>
<li class=""><span>{  </span></li>
<li class="alt">
<span>echo"</span><span class="tag"><strong><font color="#006699"></font></strong></span><span class="attribute"><font color="#ff0000">scriptlanguage</font></span><span class="tag-name"><strong><font color="#006699">scriptlanguage</font></strong></span><span>=</span><span class="attribute-value"><font color="#0000ff">'javascript'</font></span><span class="tag"><strong><font color="#006699">></font></strong></span><span>alert('初始化请选择ONE或者ANY')</span><strong><font color="#006699"><span class="tag"></span><span class="tag-name">script</span><span class="tag">></span></font></strong><span>";  </span>
</li>
<li class=""><span>exit;  </span></li>
<li class="alt"><span>}  </span></li>
<li class="">
<span>$this-</span><span class="tag"><strong><font color="#006699">></font></strong></span><span class="attribute"><font color="#ff0000">uploadtype</font></span><span>=$type;  </span>
</li>
<li class="alt">
<span>$this-</span><span class="tag"><strong><font color="#006699">></font></strong></span><span class="attribute"><font color="#ff0000">file</font></span><span>=$file;  </span>
</li>
<li class=""><span>}  </span></li>
<li class="alt"><span> </span></li>
<li class=""><span>privatefunctioncreateFileName()  </span></li>
<li class="alt"><span>{  </span></li>
<li class="">
<span>return$this-</span><span class="tag"><strong><font color="#006699">></font></strong></span><span class="attribute"><font color="#ff0000">filename</font></span><span>=</span><span class="attribute-value"><font color="#0000ff">"TTR_"</font></span><span>.time().$this-</span><span class="tag"><strong><font color="#006699">></font></strong></span><span>getRandomN(4);  </span>
</li>
<li class="alt"><span>}  </span></li>
<li class=""><span> </span></li>
<li class="alt"><span>privatefunctiongetUploadPath()  </span></li>
<li class=""><span>{  </span></li>
<li class="alt">
<span>if(substr($this-</span><span class="tag"><strong><font color="#006699">></font></strong></span><span>uploadpath,-1,1)!="/")  </span>
</li>
<li class=""><span>{  </span></li>
<li class="alt">
<span>$this-</span><span class="tag"><strong><font color="#006699">></font></strong></span><span class="attribute"><font color="#ff0000">savepath</font></span><span>=$this-</span><span class="tag"><strong><font color="#006699">></font></strong></span><span>uploadpath."/".date("Ym");  </span>
</li>
<li class=""><span>}else{  </span></li>
<li class="alt">
<span>$this-</span><span class="tag"><strong><font color="#006699">></font></strong></span><span class="attribute"><font color="#ff0000">savepath</font></span><span>=$this-</span><span class="tag"><strong><font color="#006699">></font></strong></span><span>uploadpath.date("Ym");  </span>
</li>
<li class=""><span>}  </span></li>
<li class="alt">
<span>$this-</span><span class="tag"><strong><font color="#006699">></font></strong></span><span class="attribute"><font color="#ff0000">savepath</font></span><span>=$this-</span><span class="tag"><strong><font color="#006699">></font></strong></span><span>getFolder($this-</span><span class="tag"><strong><font color="#006699">></font></strong></span><span>savepath);  </span>
</li>
<li class=""><span>returntrue;  </span></li>
<li class="alt"><span>}  </span></li>
<li class=""><span> </span></li>
<li class="alt"><span>privatefunctiongetFileExt($tempfilename)  </span></li>
<li class=""><span>{  </span></li>
<li class="alt"><span>returnend(explode(".",$tempfilename));  </span></li>
<li class=""><span>}  </span></li>
<li class="alt"><span> </span></li>
<li class=""><span>privatefunctiongetExt()  </span></li>
<li class="alt"><span>{  </span></li>
<li class="">
<span>if(in_array(strtolower($this-</span><span class="tag"><strong><font color="#006699">></font></strong></span><span>getFileExt($tempfilename)),$this-</span><span class="tag"><strong><font color="#006699">></font></strong></span><span>ext))  </span>
</li>
<li class="alt"><span>{  </span></li>
<li class=""><span>returntrue;  </span></li>
<li class="alt"><span>}else{  </span></li>
<li class=""><span>returnfalse;  </span></li>
<li class="alt"><span>}  </span></li>
<li class=""><span>}  </span></li>
<li class="alt"><span> </span></li>
<li class=""><span>privatefunctiongetFolder($folder)  </span></li>
<li class="alt"><span>{  </span></li>
<li class=""><span>if(!is_dir($folder))  </span></li>
<li class="alt"><span>{  </span></li>
<li class=""><span>mkdir($folder);  </span></li>
<li class="alt"><span>}  </span></li>
<li class=""><span>return$folder."/";  </span></li>
<li class="alt"><span>}  </span></li>
<li class=""><span> </span></li>
<li class="alt"><span> </span></li>
<li class=""><span>publicfunctionupload()  </span></li>
<li class="alt"><span>{  </span></li>
<li class="">
<span>if($this-</span><span class="tag"><strong><font color="#006699">></font></strong></span><span class="attribute"><font color="#ff0000">uploadtype</font></span><span>=="ONE")  </span>
</li>
<li class="alt"><span>{  </span></li>
<li class=""><span> </span></li>
<li class="alt"><span> </span></li>
<li class="">
<span>if($this-</span><span class="tag"><strong><font color="#006699">></font></strong></span><span>getExt($this-</span><span class="tag"><strong><font color="#006699">></font></strong></span><span>file["type"]))  </span>
</li>
<li class="alt"><span>{  </span></li>
<li class=""><span> </span></li>
<li class="alt"><span>parent::errorExt();  </span></li>
<li class=""><span> </span></li>
<li class="alt">
<span>}elseif($this-</span><span class="tag"><strong><font color="#006699">></font></strong></span><span>file["size"]</span><span class="tag"><strong><font color="#006699">></font></strong></span><span>self::filesize){  </span>
</li>
<li class=""><span> </span></li>
<li class="alt"><span>parent::errorFileSize();  </span></li>
<li class=""><span> </span></li>
<li class="alt">
<span>}elseif(!$this-</span><span class="tag"><strong><font color="#006699">></font></strong></span><span>getUploadPath()){  </span>
</li>
<li class=""><span> </span></li>
<li class="alt"><span>parent::errorUploadPath();  </span></li>
<li class=""><span> </span></li>
<li class="alt"><span>}else{  </span></li>
<li class="">
<span>$</span><span class="attribute"><font color="#ff0000">filenametemp</font></span><span>=$this-</span><span class="tag"><strong><font color="#006699">></font></strong></span><span>createFileName();  </span>
</li>
<li class="alt">
<span>$</span><span class="attribute"><font color="#ff0000">filename</font></span><span>=$this-</span><span class="tag"><strong><font color="#006699">></font></strong></span><span>savepath.$filenametemp.".".$this-</span><span class="tag"><strong><font color="#006699">></font></strong></span><span>getFileExt($this-</span><span class="tag"><strong><font color="#006699">></font></strong></span><span>file["name"]);  </span>
</li>
<li class="">
<span>if(move_uploaded_file($this-</span><span class="tag"><strong><font color="#006699">></font></strong></span><span>file["tmp_name"],$filename))  </span>
</li>
<li class="alt"><span>{  </span></li>
<li class="">
<span>$this-</span><span class="tag"><strong><font color="#006699">></font></strong></span><span class="attribute"><font color="#ff0000">uploadfilename</font></span><span>=$filenametemp;  </span>
</li>
<li class="alt"><span>parent::okMoved();  </span></li>
<li class=""><span> </span></li>
<li class="alt"><span> </span></li>
<li class=""><span>}else{  </span></li>
<li class="alt"><span>parent::errorMoveUpload();  </span></li>
<li class=""><span>}  </span></li>
<li class="alt"><span>}  </span></li>
<li class="">
<span>}elseif($this-</span><span class="tag"><strong><font color="#006699">></font></strong></span><span class="attribute"><font color="#ff0000">uploadtype</font></span><span>=="ANY"){  </span>
</li>
<li class="alt"><span> </span></li>
<li class="">
<span>for($</span><span class="attribute"><font color="#ff0000">i</font></span><span>=</span><span class="attribute-value"><font color="#0000ff">0</font></span><span>;$i</span><strong><font color="#006699"><span class="tag"><span class="tag-name">count</span></span></font></strong><span>($this-</span><span class="tag"><strong><font color="#006699">></font></strong></span><span>file);$i++)  </span>
</li>
<li class="alt"><span>{  </span></li>
<li class=""><span> </span></li>
<li class="alt">
<span>if($this-</span><span class="tag"><strong><font color="#006699">></font></strong></span><span>getExt($this-</span><span class="tag"><strong><font color="#006699">></font></strong></span><span>file[$i]["type"]))  </span>
</li>
<li class=""><span>{  </span></li>
<li class="alt"><span>parent::errorExt();  </span></li>
<li class=""><span> </span></li>
<li class="alt">
<span>}elseif($this-</span><span class="tag"><strong><font color="#006699">></font></strong></span><span>file[$i]["size"]</span><span class="tag"><strong><font color="#006699">></font></strong></span><span>self::filesize){  </span>
</li>
<li class=""><span> </span></li>
<li class="alt"><span>parent::errorFileSize();  </span></li>
<li class=""><span> </span></li>
<li class="alt">
<span>}elseif(!$this-</span><span class="tag"><strong><font color="#006699">></font></strong></span><span>getUploadPath()){  </span>
</li>
<li class=""><span> </span></li>
<li class="alt"><span>parent::errorUploadPath();  </span></li>
<li class=""><span> </span></li>
<li class="alt"><span>}else{  </span></li>
<li class="">
<span>$</span><span class="attribute"><font color="#ff0000">filenametemp</font></span><span>=$this-</span><span class="tag"><strong><font color="#006699">></font></strong></span><span>createFileName();  </span>
</li>
<li class="alt">
<span>$</span><span class="attribute"><font color="#ff0000">filename</font></span><span>=$this-</span><span class="tag"><strong><font color="#006699">></font></strong></span><span>savepath.$filenametemp.".".$this-</span><span class="tag"><strong><font color="#006699">></font></strong></span><span>getFileExt($this-</span><span class="tag"><strong><font color="#006699">></font></strong></span><span>file[$i]["name"]);  </span>
</li>
<li class="">
<span>if(move_uploaded_file($this-</span><span class="tag"><strong><font color="#006699">></font></strong></span><span>file[$i]["tmp_name"],$filename))  </span>
</li>
<li class="alt"><span>{  </span></li>
<li class="">
<span>$</span><span class="attribute"><font color="#ff0000">str.</font></span><span>=$filenametemp."|";  </span>
</li>
<li class="alt"><span> </span></li>
<li class=""><span>}else{  </span></li>
<li class="alt"><span>parent::errorMoveUpload();  </span></li>
<li class=""><span>}  </span></li>
<li class="alt"><span> </span></li>
<li class=""><span>}  </span></li>
<li class="alt"><span> </span></li>
<li class=""><span>}  </span></li>
<li class="alt">
<span>$this-</span><span class="tag"><strong><font color="#006699">></font></strong></span><span class="attribute"><font color="#ff0000">uploadfilename</font></span><span>=</span><span class="attribute-value"><font color="#0000ff">substr</font></span><span>($str,0,strlen($str)-1);  </span>
</li>
<li class=""><span>parent::okMoved();  </span></li>
<li class="alt"><span>}  </span></li>
<li class=""><span>}  </span></li>
<li class="alt"><span> </span></li>
<li class=""><span>publicfunctiongetUploadFileName()  </span></li>
<li class="alt"><span>{  </span></li>
<li class="">
<span>return$this-</span><span class="tag"><strong><font color="#006699">></font></strong></span><span>uploadfilename;  </span>
</li>
<li class="alt"><span>}  </span></li>
<li class=""><span> </span></li>
<li class="alt"><span>publicfunctionsetUploadPath($path)  </span></li>
<li class=""><span>{  </span></li>
<li class="alt">
<span>$this-</span><span class="tag"><strong><font color="#006699">></font></strong></span><span class="attribute"><font color="#ff0000">uploadpath</font></span><span>=$path;  </span>
</li>
<li class=""><span>}  </span></li>
<li class="alt"><span> </span></li>
<li class=""><span> </span></li>
<li class="alt"><span>privatefunctiongetRandomN($n)  </span></li>
<li class=""><span>{  </span></li>
<li class="alt">
<span>if($n</span><strong><font color="#006699"><span class="tag"><span class="tag-name">1</span></span></font></strong><span>||$n</span><span class="tag"><strong><font color="#006699">></font></strong></span><span>10)return"";  </span>
</li>
<li class=""><span> </span></li>
<li class="alt">
<span>$</span><span class="attribute"><font color="#ff0000">ary_num</font></span><span>=</span><span class="attribute-value"><font color="#0000ff">array</font></span><span>(0,1,2,3,4,5,6,7,8,9);  </span>
</li>
<li class="">
<span>$</span><span class="attribute"><font color="#ff0000">return</font></span><span>=</span><span class="attribute-value"><font color="#0000ff">""</font></span><span>;  </span>
</li>
<li class="alt">
<span>for($</span><span class="attribute"><font color="#ff0000">i</font></span><span>=</span><span class="attribute-value"><font color="#0000ff">0</font></span><span>;$i</span><span class="tag"><strong><font color="#006699"></font></strong></span><span>$n;$i++)  </span>
</li>
<li class=""><span>{  </span></li>
<li class="alt">
<span>$</span><span class="attribute-value"><font color="#0000ff">rand</font></span><span class="attribute"><font color="#ff0000">randn</font></span><span>=rand(0,9-$i);  </span>
</li>
<li class="">
<span>$</span><span class="attribute"><font color="#ff0000">return.</font></span><span>=$ary_num[$randn];  </span>
</li>
<li class="alt"><span>$ary_num[$randn]=$ary_num[9-$i];  </span></li>
<li class=""><span>}  </span></li>
<li class="alt"><span>return$return;  </span></li>
<li class=""><span>}  </span></li>
<li class="alt"><span> </span></li>
<li class=""><span> </span></li>
<li class="alt"><span> </span></li>
<li class=""><span>publicfunction__destruct()  </span></li>
<li class="alt"><span>{  </span></li>
<li class="">
<span>$this-</span><span class="tag"><strong><font color="#006699">></font></strong></span><span class="attribute"><font color="#ff0000">uploadfilename</font></span><span>=</span><span class="attribute-value"><font color="#0000ff">null</font></span><span>;  </span>
</li>
<li class="alt">
<span>$this-</span><span class="tag"><strong><font color="#006699">></font></strong></span><span class="attribute"><font color="#ff0000">uploadtype</font></span><span>=</span><span class="attribute-value"><font color="#0000ff">null</font></span><span>;  </span>
</li>
<li class="">
<span>$this-</span><span class="tag"><strong><font color="#006699">></font></strong></span><span class="attribute"><font color="#ff0000">file</font></span><span>=</span><span class="attribute-value"><font color="#0000ff">null</font></span><span>;  </span>
</li>
<li class="alt">
<span>$this-</span><span class="tag"><strong><font color="#006699">></font></strong></span><span class="attribute"><font color="#ff0000">savepath</font></span><span>=</span><span class="attribute-value"><font color="#0000ff">null</font></span><span>;  </span>
</li>
<li class=""><span>}  </span></li>
<li class="alt"><span> </span></li>
<li class=""><span>}  </span></li>
<li class="alt"><span> </span></li>
<li class=""><span>classError  </span></li>
<li class="alt"><span>{  </span></li>
<li class=""><span>publicstaticfunctionerrorFileSize()  </span></li>
<li class="alt"><span>{  </span></li>
<li class=""><span>echo"超出最大上传限制";  </span></li>
<li class="alt"><span>}  </span></li>
<li class=""><span> </span></li>
<li class="alt"><span>publicstaticfunctionerrorExt()  </span></li>
<li class=""><span>{  </span></li>
<li class="alt"><span>echo"此类文件不允许上传";  </span></li>
<li class=""><span>}  </span></li>
<li class="alt"><span> </span></li>
<li class=""><span>publicstaticfunctionerrorUploadPath()  </span></li>
<li class="alt"><span>{  </span></li>
<li class=""><span>echo"上传路径不正确";  </span></li>
<li class="alt"><span>}  </span></li>
<li class=""><span> </span></li>
<li class="alt"><span>publicstaticfunctionerrorMoveUpload()  </span></li>
<li class=""><span>{  </span></li>
<li class="alt"><span>echo"上传失败";  </span></li>
<li class=""><span>}  </span></li>
<li class="alt"><span> </span></li>
<li class=""><span>publicstaticfunctionokMoved()  </span></li>
<li class="alt"><span>{  </span></li>
<li class=""><span>echo"上传成功!";  </span></li>
<li class="alt"><span>}  </span></li>
<li class=""><span> </span></li>
<li class="alt"><span>publicstaticfunctionokArrayMoved()  </span></li>
<li class=""><span>{  </span></li>
<li class="alt"><span>echo"上传成功!";  </span></li>
<li class=""><span>} </span></li>
</ol>
로그인 후 복사

본 웹사이트의 성명
본 글의 내용은 네티즌들의 자발적인 기여로 작성되었으며, 저작권은 원저작자에게 있습니다. 본 사이트는 이에 상응하는 법적 책임을 지지 않습니다. 표절이나 침해가 의심되는 콘텐츠를 발견한 경우 admin@php.cn으로 문의하세요.

핫 AI 도구

Undresser.AI Undress

Undresser.AI Undress

사실적인 누드 사진을 만들기 위한 AI 기반 앱

AI Clothes Remover

AI Clothes Remover

사진에서 옷을 제거하는 온라인 AI 도구입니다.

Undress AI Tool

Undress AI Tool

무료로 이미지를 벗다

Clothoff.io

Clothoff.io

AI 옷 제거제

AI Hentai Generator

AI Hentai Generator

AI Hentai를 무료로 생성하십시오.

인기 기사

R.E.P.O. 에너지 결정과 그들이하는 일 (노란색 크리스탈)
3 몇 주 전 By 尊渡假赌尊渡假赌尊渡假赌
R.E.P.O. 최고의 그래픽 설정
3 몇 주 전 By 尊渡假赌尊渡假赌尊渡假赌
R.E.P.O. 아무도들을 수없는 경우 오디오를 수정하는 방법
3 몇 주 전 By 尊渡假赌尊渡假赌尊渡假赌
WWE 2K25 : Myrise에서 모든 것을 잠금 해제하는 방법
4 몇 주 전 By 尊渡假赌尊渡假赌尊渡假赌

뜨거운 도구

메모장++7.3.1

메모장++7.3.1

사용하기 쉬운 무료 코드 편집기

SublimeText3 중국어 버전

SublimeText3 중국어 버전

중국어 버전, 사용하기 매우 쉽습니다.

스튜디오 13.0.1 보내기

스튜디오 13.0.1 보내기

강력한 PHP 통합 개발 환경

드림위버 CS6

드림위버 CS6

시각적 웹 개발 도구

SublimeText3 Mac 버전

SublimeText3 Mac 버전

신 수준의 코드 편집 소프트웨어(SublimeText3)

Ubuntu 및 Debian용 PHP 8.4 설치 및 업그레이드 가이드 Ubuntu 및 Debian용 PHP 8.4 설치 및 업그레이드 가이드 Dec 24, 2024 pm 04:42 PM

PHP 8.4는 상당한 양의 기능 중단 및 제거를 통해 몇 가지 새로운 기능, 보안 개선 및 성능 개선을 제공합니다. 이 가이드에서는 Ubuntu, Debian 또는 해당 파생 제품에서 PHP 8.4를 설치하거나 PHP 8.4로 업그레이드하는 방법을 설명합니다.

CakePHP 날짜 및 시간 CakePHP 날짜 및 시간 Sep 10, 2024 pm 05:27 PM

cakephp4에서 날짜와 시간을 다루기 위해 사용 가능한 FrozenTime 클래스를 활용하겠습니다.

CakePHP 토론 CakePHP 토론 Sep 10, 2024 pm 05:28 PM

CakePHP는 PHP용 오픈 소스 프레임워크입니다. 이는 애플리케이션을 훨씬 쉽게 개발, 배포 및 유지 관리할 수 있도록 하기 위한 것입니다. CakePHP는 강력하고 이해하기 쉬운 MVC와 유사한 아키텍처를 기반으로 합니다. 모델, 뷰 및 컨트롤러 gu

CakePHP 파일 업로드 CakePHP 파일 업로드 Sep 10, 2024 pm 05:27 PM

파일 업로드 작업을 위해 양식 도우미를 사용할 것입니다. 다음은 파일 업로드의 예입니다.

CakePHP 유효성 검사기 만들기 CakePHP 유효성 검사기 만들기 Sep 10, 2024 pm 05:26 PM

컨트롤러에 다음 두 줄을 추가하면 유효성 검사기를 만들 수 있습니다.

PHP 개발을 위해 Visual Studio Code(VS Code)를 설정하는 방법 PHP 개발을 위해 Visual Studio Code(VS Code)를 설정하는 방법 Dec 20, 2024 am 11:31 AM

VS Code라고도 알려진 Visual Studio Code는 모든 주요 운영 체제에서 사용할 수 있는 무료 소스 코드 편집기 또는 통합 개발 환경(IDE)입니다. 다양한 프로그래밍 언어에 대한 대규모 확장 모음을 통해 VS Code는

CakePHP 빠른 가이드 CakePHP 빠른 가이드 Sep 10, 2024 pm 05:27 PM

CakePHP는 오픈 소스 MVC 프레임워크입니다. 이를 통해 애플리케이션 개발, 배포 및 유지 관리가 훨씬 쉬워집니다. CakePHP에는 가장 일반적인 작업의 과부하를 줄이기 위한 여러 라이브러리가 있습니다.

PHP에서 HTML/XML을 어떻게 구문 분석하고 처리합니까? PHP에서 HTML/XML을 어떻게 구문 분석하고 처리합니까? Feb 07, 2025 am 11:57 AM

이 튜토리얼은 PHP를 사용하여 XML 문서를 효율적으로 처리하는 방법을 보여줍니다. XML (Extensible Markup Language)은 인간의 가독성과 기계 구문 분석을 위해 설계된 다목적 텍스트 기반 마크 업 언어입니다. 일반적으로 데이터 저장 AN에 사용됩니다

See all articles