?? ??? ?? ?? ???
?? ??? ??? ?? ?? ??? ??? ?? ???? ?? ??? ? ? ????:
<!DOCTYPE html> <html lang="en"> <head> <meta charset="UTF-8"> <title>Title</title> </head> <script > var change=document.getElementById('change_code'); var code_img=document.getElementById('code_img'); change.onclick=function () { code_img.src='code.php?time='+new Date(); return false; } </script> <body> <form action="check.php" method="post"> 用戶名:<input type="text" id="username" name="username"/><br> 密碼:<input type="password" id="password" name="password" /><br> 驗證碼:<input type="text" id="code" name="code" /><img id="code_img" src="code.php" /><a id="change_code" href="">看不清,換一張</a><br> <div id="error_message" style="color: red"></div> <input type="submit" id='login' name='login' value="登錄"> </form> </body> </html>
??? ??:
???? ??:
?? ? ?? ??? ??? ?? ??, ? ??? ??? ???????. ? ?????
? ??? Windows ?? ???? ??? ??? ?? ?????. ??? ????:
?? ?? ????? ????. ???? ?????? ?? ??? ?? ?? ????? ?? ?? ??? ????? ??? ? ? ????
???? ??? ??? ????
<?php function getFileList($path){ //保存打開文件的句柄 $handle=opendir($path); //保存文件列表數(shù)組,dir保存目錄,file保存文件 $list=array('dir'=>array(),'file'=>array()); //循環(huán)遍歷文件列表 while(false!==($filename=readdir($handle))){ //排除當(dāng)前目錄和父級目錄 if($filename!='.' && $filename!='..'){ //處理文件路徑和文件名 $filepath="$path/$filename"; //根據(jù)路徑獲取文件類型 $filetype=filetype($filepath); //如果既不是文件也不是目錄,則跳過 if(!in_array($filetype,array('file','dir'))){ continue; } //將文件信息保存到數(shù)組中 $list[$filetype][]=array( //保存文件名和路勁 'filename'=>$filename, 'filepath'=>$filepath, //保存各種屬性 'filesize'=>round(filesize($filepath)/1024), 'filemtime'=>date('Y/m/d H:i:s',filemtime($filepath)), ); } } //關(guān)閉文件句柄 closedir($handle); return $list; $path="."; $file_list=getFileList($path); echo "<pre>"; print_r($file_list); echo "</pre>";
???? ??? ??? ????.
?? ??? ??? ????.
?? ?? html? ?????. ???? Windows ???? ??? ???? ?? ??? file_list? ?????.
filemanager_html.php ??? ??? ????.
<?php /** * Created by PhpStorm. * User: Administrator * Date: 2018/3/1 0001 * Time: 下午 1:54 */ ?> <html> <head> <meta charset="utf-8"> <title>文件管理器</title> </head> <body> <!--文件列表區(qū)--> <table> <tr><th>名稱</th><th>修改日期</th><th>大小</th><th>操作</th></tr> <!-- 循環(huán)輸出目錄列表--> <?php foreach ($file_list['dir'] as $v): ?> <tr><td><img src="./img/dir.png"><?php echo $v['filename'];?></td> <td><?php echo $v['filename'];?></td> <td>-</td> <td><a href="">打開</a></td> </tr> <?php endforeach;?> <!-- 循環(huán)輸出文件列表--> <?php foreach($file_list['file'] as $v): ?> <tr> <td><img src="./img/file.png"><?php echo $v['filename'];?></td> <td><?php echo $v['filemtime'];?></td> <td><?php echo $v['filesize'];?>KB</td> <td> <a href="">重命名</a><a href="">復(fù)制</a><a href="">刪除</a> </td> </tr> <?php endforeach;?> </table> </body> </html>
?? ??? ?????.
???? ?? ???? ??, ?? ???, ?? ? ??? ?? ?? ??? ???? ??? ?????? (?? ???? ???????)