|
<html xmlns=&#34;http://www.w3.org/1999/xhtml&#34; xml:lang=&#34;en&#34;> <head> <meta http-equiv=&#34;Content-Type&#34; content=&#34;text/html; charset=utf-8&#34;> </head> <form enctype=&#34;multipart/form-data&#34; method=&#34;post&#34;> <p>请选择要上传的图片:<p> <input class=&#34;input_file&#34; type=&#34;file&#34; name=&#34;upload_file&#34;/> <input class=&#34;button&#34; type=&#34;submit&#34; name=&#34;submit&#34; value=&#34;上传&#34;/> </form></html><?php //highlight_file(__FILE__); //$key = &#39;51d0a99c-752e-11ed-b5a7-44af28a75237&#39;; if (isset($_POST[&#39;submit&#39;])){ $file_name = trim($_FILES[&#39;upload_file&#39;][&#39;name&#39;]); $black = array(&#34;.php&#34;,&#34;.php5&#34;,&#34;.php4&#34;,&#34;.php3&#34;,&#34;.php2&#34;,&#34;.html&#34;,&#34;.htm&#34;,&#34;.phtml&#34;,&#34;.pht&#34;,&#34;.pHp&#34;,&#34;.pHp5&#34;,&#34;.pHp4&#34;,&#34;.pHp3&#34;,&#34;.pHp2&#34;,&#34;.Html&#34;,&#34;.Htm&#34;,&#34;.pHtml&#34;,&#34;.jsp&#34;,&#34;.jspa&#34;,&#34;.jspx&#34;,&#34;.jsw&#34;,&#34;.jsv&#34;,&#34;.jspf&#34;,&#34;.jtml&#34;,&#34;.jSp&#34;,&#34;.jSpx&#34;,&#34;.jSpa&#34;,&#34;.jSw&#34;,&#34;.jSv&#34;,&#34;.jSpf&#34;,&#34;.jHtml&#34;,&#34;.asp&#34;,&#34;.aspx&#34;,&#34;.asa&#34;,&#34;.asax&#34;,&#34;.ascx&#34;,&#34;.ashx&#34;,&#34;.asmx&#34;,&#34;.cer&#34;,&#34;.aSp&#34;,&#34;.aSpx&#34;,&#34;.aSa&#34;,&#34;.aSax&#34;,&#34;.aScx&#34;,&#34;.aShx&#34;,&#34;.aSmx&#34;,&#34;.cEr&#34;,&#34;.sWf&#34;,&#34;.swf&#34;,&#34;.htaccess&#34;,&#34;.ini&#34;); $file_ext = strrchr($file_name, &#39;.&#39;); $file_ext = strtolower($file_ext); //echo $file_ext; if (!in_array($file_ext, $black)){ $temp_file = $_FILES[&#39;upload_file&#39;][&#39;tmp_name&#39;]; $img_path = &#39;upload&#39;.&#39;/&#39;.date(&#34;His&#34;).rand(100,999).$file_ext; if (move_uploaded_file($temp_file, $img_path)) { $is_upload = true; } else { $msg = &#39;上传出错!&#39;; } }else { $msg = &#39;This file type cannot be uploaded&#39;; } } if($msg != null){ echo &#34;提示:&#34;.$msg; } if($is_upload){ echo &#39;ok&#39;; }?> |
|