[PHP文件管理器]①⑧--上傳文件

修改代碼

<a href="#" onclick="show('uploadFile')" title="上傳文件"><span
style="margin-left: 8px; margin-top: 0px; top: 4px;"
="icon icon-small icon-square"><span class="icon-upload"></span></span></a>
<tr id="uploadFile" style="display: none;">
                <td>請選擇要上傳的文件</td>
                <td><input type="file" name="myFile" /> <input type="submit"
                    name="act" value="上傳文件" /></td>
            </tr>
function getExt($filename){
    return strtolower(pathinfo($filename,PATHINFO_EXTENSION));
}

function getUniqidName($length=10){
    //uniqid 如果 prefix 參數為空,則返回的字符串有 13 個字符串長。
    //如果 more_entropy 參數設置為 true,則是 23 個字符串長
    return substr(md5(uniqid(microtime(true),true)),0,$length);
}
function uploadFile($fileInfo, $path, $allowExt = array('gif','jpeg','jpg','png','txt'), $maxSize = 10485760) {
    // 判斷錯誤號
    if ($fileInfo ['error'] == UPLOAD_ERR_OK) {
        // 文件是否是通過HTTP POST方式上傳上來的
        if (is_uploaded_file ( $fileInfo ['tmp_name'] )) {
            // 上傳的文件的文件名,只允許上傳jpeg png gif txt
            
            $ext = getExt ( $fileInfo ['name'] );
            $uniqid = getUniqidName ();
            $destination = $path . "/" . pathinfo ( $fileInfo ['name'], PATHINFO_FILENAME ) . "_" . $uniqid . "." . $ext;
            if (in_array ( $ext, $allowExt )) {
                // 10M
                if ($fileInfo ['size'] <= $maxSize) {
                    if (move_uploaded_file ( $fileInfo ['tmp_name'], $destination )) {
                        $mes = "文件上傳成功";
                    } else {
                        $mes = "文件過大";
                    }
                } else {
                    $mes = "文件過大";
                }
            } else {
                $mes = "非法文件類型";
            }
        } else {
            $mes = "文件不是通過HTTP POST方式上傳上來的";
        }
    } else {
        switch ($fileInfo ['error']) {
            case 1 :
                $mes = "超過了配置文件的大小";
                break;
            case 2 :
                $mes = "超過了表單允許接收數據的大小";
                break;
            case 3 :
                $mes = "文件部分被上傳";
                break;
            case 4 :
                $mes = "沒有文件被上傳";
                break;
        }
    }
    return $mes;
}

else if($act=='上傳文件'){
    /*
    Array
    (
        [myFile] => Array
            (
                [name] => Git及SVN地址.txt
                [type] => text/plain
                [tmp_name] => C:\wamp\tmp\phpA6E9.tmp
                [error] => 0
                [size] => 205
            )

    )
     * 
     */
    //print_r($_FILES);
    
    
    $fileInfo=$_FILES['myFile'];
    $mes=uploadFile($fileInfo,$path);
    alertMes($mes, $redirect);
}

common.func.php

<?php
/**
 * 提示信息并跳轉
 * @param string $mes
 * @param string $url
 */
function alertMes($mes, $url) {
    echo "<script type='text/javascript' charset='gbk'>alert('$mes');location.href='$url'</script>";
}
function getExt($filename) {
    return strtolower ( pathinfo ( $filename, PATHINFO_EXTENSION ) );
}
function getUniqidName($length = 10) {
    // uniqid 如果 prefix 參數為空,則返回的字符串有 13 個字符串長。
    // 如果 more_entropy 參數設置為 true,則是 23 個字符串長
    return substr ( md5 ( uniqid ( microtime ( true ), true ) ), 0, $length );
}
?>

file.func.php

<?php

// require_once 'common.func.php';
/**
 * 轉化字節大小
 * 
 * @param number $size          
 * @return number
 */
function transByte($size) {
    // Bytes/KB/MB/GB/TB/EB
    $arr = array (
            "B",
            "KB",
            "MB",
            "GB",
            "TB",
            "TB" 
    );
    $i = 0;
    while ( $size > 1024 ) {
        $size /= 1024;
        $i ++;
    }
    return round ( $size, 2 ) . $arr [$i];
}
function createFile($filename) {
    // file/1.txt
    // 驗證文件名的合法性,是否包含/,*,<,>,?,|
    $pattern = "/[\/,\*,<>,\?\|]/";
    // basename 返回路徑中的文件名部分
    if (! (preg_match ( $pattern, basename ( $filename ) ))) {
        // 檢測當前目錄下是否存在同名文件
        if (! file_exists ( $filename )) {
            // 通過touch創建
            if (touch ( $filename )) {
                return "創建文件成功";
            } else {
                return "創建文件失敗";
            }
        } else {
            return "文件已存在";
        }
    } else {
        return "包含非法字符";
    }
}
function renameFile($oldname, $newname) {
    // 驗證文件名是否合法
    if (checkFilename ( $newname )) {
        // 檢測當前目錄下是否存在同名文件
        $path = dirname ( $oldname );
        if (! file_exists ( $path . "/" . $newname )) {
            // 進行重命名
            if (rename ( $oldname, $path . "/" . $newname )) {
                return "重命名成功";
            } else {
                return "重命名失敗";
            }
        } else {
            return "存在同名文件,請重新命名";
        }
    } else {
        return "非法文件名";
    }
}
function checkFilename($filename) {
    // 驗證文件名的合法性,是否包含/,*,<,>,?,|
    $pattern = "/[\/,\*,<>,\?\|]/";
    // basename 返回路徑中的文件名部分
    if (preg_match ( $pattern, $filename )) {
        return false;
    } else {
        return true;
    }
}
function deleteFile($filename) {
    if (unlink ( $filename )) {
        $mes = "文件刪除成功";
    } else {
        $mes = "文件刪除失敗";
    }
    return $mes;
}
function downFile($filename) {
    header ( "content-disposition:attachment;filename=" . basename ( $filename ) );
    header ( "content-length:" . filesize ( $filename ) );
    readfile ( $filename );
}
function copyFile($filename, $dstname) {
    if (file_exists ( $dstname )) {
        if (! file_exists ( $dstname . "/" . basename ( $filename ) )) {
            if (copy ( $filename, $dstname . "/" . basename ( $filename ) )) {
                $mes = "文件復制成功";
            } else {
                $mes = "文件復制失敗";
            }
        } else {
            $mes = "存在同名文件";
        }
    } else {
        $mes = "目標目錄不存在";
    }
    return $mes;
}
function cutFile($filename, $dstname) {
    if (file_exists ( $dstname )) {
        if (! file_exists ( $dstname . "/" . basename ( $filename ) )) {
            if (rename ( $filename, $dstname . "/" . basename ( $filename ) )) {
                $mes = "文件剪切成功";
            } else {
                $mes = "文件剪切失敗";
            }
        } else {
            $mes = "存在同名文件";
        }
    } else {
        $mes = "目標目錄不存在";
    }
    return $mes;
}
function uploadFile($fileInfo, $path, $allowExt = array('gif','jpeg','jpg','png','txt'), $maxSize = 10485760) {
    // 判斷錯誤號
    if ($fileInfo ['error'] == UPLOAD_ERR_OK) {
        // 文件是否是通過HTTP POST方式上傳上來的
        if (is_uploaded_file ( $fileInfo ['tmp_name'] )) {
            // 上傳的文件的文件名,只允許上傳jpeg png gif txt
            
            $ext = getExt ( $fileInfo ['name'] );
            $uniqid = getUniqidName ();
            $destination = $path . "/" . pathinfo ( $fileInfo ['name'], PATHINFO_FILENAME ) . "_" . $uniqid . "." . $ext;
            if (in_array ( $ext, $allowExt )) {
                // 10M
                if ($fileInfo ['size'] <= $maxSize) {
                    if (move_uploaded_file ( $fileInfo ['tmp_name'], $destination )) {
                        $mes = "文件上傳成功";
                    } else {
                        $mes = "文件過大";
                    }
                } else {
                    $mes = "文件過大";
                }
            } else {
                $mes = "非法文件類型";
            }
        } else {
            $mes = "文件不是通過HTTP POST方式上傳上來的";
        }
    } else {
        switch ($fileInfo ['error']) {
            case 1 :
                $mes = "超過了配置文件的大小";
                break;
            case 2 :
                $mes = "超過了表單允許接收數據的大小";
                break;
            case 3 :
                $mes = "文件部分被上傳";
                break;
            case 4 :
                $mes = "沒有文件被上傳";
                break;
        }
    }
    return $mes;
}

?>

index.php

<?php
require_once ('dir.func.php');
require_once 'file.func.php';
require_once 'common.func.php';

$path = 'file';
$path = isset ( $_REQUEST ['path'] ) ? $_REQUEST ['path'] : $path;
$arr = readDirectory ( $path );
$act = isset ( $_REQUEST ['act'] ) ? $_REQUEST ['act'] : '';
$filename = isset ( $_REQUEST ['filename'] ) ? $_REQUEST ['filename'] : '?';
$redirect = "index.php?path={$path}";
$dirname = isset ( $_REQUEST ['dirname'] ) ? $_REQUEST ['dirname'] : '';
// echo $act."<br/>";
// echo $filename;

if (! (isset ( $arr ['file'] )) && ! (isset ( $arr ['dir'] ))) {
    echo "<script>alert('沒有文件或目錄!');location.href='index.php';</script>";
}

if ($act == '創建文件') {
    $mes = createFile ( $path . "/" . $filename );
    alertMes ( $mes, $redirect );
} else if ($act == 'showContent') {
    // 查看文件內容
    $content = file_get_contents ( $filename );
    if (strlen ( $content )) {
        // textarea能完整顯示代碼
        // echo "<textarea col='1000' rows='10'>$content</textarea>";
        
        // 高亮顯示字符創中的PHP代碼 true不自動輸出(echo)
        $newContent = highlight_string ( $content, true );
        // 高亮顯示文件中的PHP代碼
        // $content=highlight_file($filename,true);
        
        $str = <<<EOF
    <table width='100%' bgcolor='pink' cellpadding='5' cellspacing='0'>
        <tr>
            <td>
                {$newContent}
            </td>
        </tr>
    </table>
EOF;
        echo $str;
    } else {
        alertMes ( "文件沒有內容,請編輯再查看!", $redirect );
    }
} else if ($act == 'editContent') {
    $content = file_get_contents ( $filename );
    $str = <<<EOF
    <form action='index.php?act=doEdit' method='post'>
        <textarea name='content' col='190' rows='10'>{$content}</textarea>
        <input type='hidden' name='filename' value='{$filename}'/>
        <input type="submit" value="修改文件內容"/>
    </form>
EOF;
    echo $str;
} else if ($act == "doEdit") {
    // 修改文件內容的操作
    $content = $_REQUEST ['content'];
    // echo $content;
    if (file_put_contents ( $filename, $content )) {
        $mes = "文件修改成功";
    } else {
        $mes = "文件修改失敗";
    }
    alertMes ( $mes, $redirect );
} else if ($act == "renameFile") {
    // 完成重命名
    $str = <<<EOF
        <form action="index.php?act=doRename" method="post">
        請填寫新文件名:<input type="text" name="newname" placeholder="重命名"/>
            <input type='hidden' name='filename' value='{$filename}'/>
            <input type="submit" value="重命名"/>
        </form>
EOF;
    echo $str;
} else if ($act == 'doRename') {
    // 實現重命名操作
    $newname = $_REQUEST ['newname'];
    $mes = renameFile ( $filename, $newname );
    alertMes ( $mes, $redirect );
} else if ($act == 'delFile') {
    $mes = deleteFile ( $filename );
    alertMes ( $mes, $redirect );
} else if ($act == 'downFile') {
    // 完成下載的操作
    $mes = downFile ( $filename );
} else if ($act == "copyFolder") {
    $str = <<<EOF
    <form action="index.php?act=doCopyFolder" method="post">
    將文件夾復制到:<input type="text" name="dstname" placeholder="將文件夾復制到"/>
            <input type="hidden" name="path" value="{$path}"/>
            <input type='hidden' name="dirname" value='{$dirname}'/>
            <input type='submit' value="復制文件夾"/>
    </form>
EOF;
    echo $str;
} else if ($act == 'doCopyFolder') {
    $dstname = $_REQUEST ['dstname'];
    
    $mes = copyFolder ( $dirname, $path . "/" . $dstname . "/" . basename ( $dirname ) );
    
    alertMes ( $mes, $redirect );
} else if ($act == 'renameFolder') {
    $str = <<<EOF
        <form action="index.php?act=doRenameFolder" method="post">
            請填寫新文件夾名稱:<input type="text" name="newname" placeholder="重命名"/>
            <input type="hidden" name="dirname" value='{$dirname}'/>
            <input type="hidden" name="path" value='{$path}'/>
            <input type="submit" value="重命名"/>
        </form>
EOF;
    echo $str;
} else if ($act == 'doRenameFolder') {
    $newname = $_REQUEST ['newname'];
    // imooc222
    // file/aa/imooc1
    // file/aa
    // echo $newname."<br/>".$dirname."<br/>".$path;
    $mes = renameFolder ( $dirname, $path . "/" . $newname );
    alertMes ( $mes, $redirect );
} else if ($act == 'cutFolder') {
    $str = <<<EOF
    <form action="index.php?act=doCutFolder" method="post">
        將文件剪切到:<input type="text" name="dstname" placeholder="將文件簡介到"/>
            <input type="hidden" name="path" value='{$path}'/>
            <input type="hidden" name="dirname" value='{$dirname}'/>
            <input type="submit" value="剪切文件夾"/>
    </form>
EOF;
    echo $str;
} else if ($act == "doCutFolder") {
    $dstname = $_REQUEST ['dstname'];
    $mes = cutFolders ( $dirname, $path . "/" . $dstname );
    alertMes ( $mes, $redirect );
} else if ($act == "delFolder") {
    $mes = delFolder ( $dirname );
    alertMes ( $mes, $redirect );
} else if ($act == 'copyFile') {
    $str = <<<EOF
        <form action="index.php?act=doCopyFile" method="post">
            將文件復制到:<input type="text" name="dstname" placeholder="將文件復制到"/>
            <input type="hidden" name="path" value="{$path}"/>
            <input type="hidden" name="dirname" value='{$filename}'/>
            <input type="submit" value="復制文件"/>
        </form>
EOF;
    echo $str;
} else if ($act == 'doCopyFile') {
    $dstname = $_REQUEST ['dstname'];
    // echo $dirname."<br/>".$path."/".$dstname;
    $mes = copyFile ( $dirname, $path . "/" . $dstname );
    alertMes ( $mes, $redirect );
} else if ($act == 'cutFile') {
    $str = <<<EOF
        <form action="index.php?act=doCutFile" method="post">
            將文件剪切到:<input type="text" name="dstname" placeholder="將文件剪切到"/>
            <input type="hidden" name="path" value="{$path}"/>
            <input type="hidden" name="dirname" value='{$filename}'/>
            <input type="submit" value="剪切文件"/>
        </form>
EOF;
    echo $str;
} else if ($act == 'doCutFile') {
    $dstname = $_REQUEST ['dstname'];
    // echo $dirname."<br/>".$path."/".$dstname;
    $mes = cutFile ( $dirname, $path . "/" . $dstname );
    alertMes ( $mes, $redirect );
} else if ($act == '上傳文件') {
    /*
     * Array ( [myFile] => Array ( [name] => Git及SVN地址.txt [type] => text/plain [tmp_name] => C:\wamp\tmp\phpA6E9.tmp [error] => 0 [size] => 205 ) )
     */
    // print_r($_FILES);
    
    $fileInfo = $_FILES ['myFile'];
    $mes = uploadFile ( $fileInfo, $path );
    alertMes ( $mes, $redirect );
}

?>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
<title>Insert title here</title>
<link rel="stylesheet" href="cikonss.css" />
<script src="jquery-ui/js/jquery-1.10.2.js"></script>
<script src="jquery-ui/js/jquery-ui-1.10.4.custom.js"></script>
<script src="jquery-ui/js/jquery-ui-1.10.4.custom.min.js"></script>
<link rel="stylesheet"
    href="jquery-ui/css/ui-lightness/jquery-ui-1.10.4.custom.css"
    type="text/css" />
<style type="text/css">
body,p,div,ul,ol,table,dl,dd,dt {
    margin: 0;
    padding: 0;
}

a {
    text-decoration: none;
}

ul,li {
    list-style: none;
    float: left;
}

#top {
    width: 100%;
    height: 48px;
    margin: 0 auto;
    background: #E2E2E2;
}

#navi a {
    display: block;
    width: 48px;
    height: 48px;
}

#main {
    margin: 0 auto;
    border: 2px solid #ABCDEF;
}

.small {
    width: 25px;
    height: 25px;
    border: 0;
}
</style>
<script type="text/javascript">
    function show(dis){
    document.getElementById(dis).style.display="block";
    }
    function delFile(filename){
        if(window.confirm("您確定要刪除嘛?刪除之后無法恢復喲!!!")){
                location.href="index.php?act=delFile&filename="+filename;
        }
        return false;
    }

    function showDetail(t,filename){
        $("#showImg").attr("src",filename);
        $("#showDetail").dialog({
              height:"auto",
              width: "auto",
              position: {my: "center", at: "center",  collision:"fit"},
              modal:false,//是否模式對話框
              draggable:true,//是否允許拖拽
              resizable:true,//是否允許拖動
              title:t,//對話框標題
              show:"slide",
              hide:"explode"
        });
        }
    
    function goBack($back){
        location.href="index.php?path="+$back;
    }

    function delFolder(dirname,path){
        if(window.confirm("您確定要刪除嘛?刪除之后無法恢復哦")){
            location.href="index.php?act=delFolder&dirname="+dirname+"&path="+path;
        }
        return false;
    }
        
</script>
</head>

<body>
    <div id="showDetail" style="display: none">
        <img src="" id="showImg" alt="" />
    </div>
    <h1>慕課網-在線文件管理器</h1>
    <div id="top">
        <ul id="navi">
            <li><a href="index.php" title="主目錄"><span
                    style="margin-left: 8px; margin-top: 0px; top: 4px;"
                    class="icon icon-small icon-square"><span class="icon-home"></span></span></a></li>
            <li><a href="#" onclick="show('createFile')" title="新建文件"><span
                    style="margin-left: 8px; margin-top: 0px; top: 4px;"
                    class="icon icon-small icon-square"><span class="icon-file"></span></span></a></li>
            <li><a href="#" onclick="show('createFolder')" title="新建文件夾"><span
                    style="margin-left: 8px; margin-top: 0px; top: 4px;"
                    class="icon icon-small icon-square"><span class="icon-folder"></span></span></a></li>
            <li><a href="#" onclick="show('uploadFile')" title="上傳文件"><span
                    style="margin-left: 8px; margin-top: 0px; top: 4px;"
                    class="icon icon-small icon-square"><span class="icon-upload"></span></span></a></li>
            <?php
            $back = ($path == 'file') ? "file" : dirname ( $path );
            ?>
            <li><a href="#" title="返回上級目錄"
                onclick="goBack('<?php echo $back;?>')"><span
                    style="margin-left: 8px; margin-top: 0px; top: 4px;"
                    class="icon icon-small icon-square"><span class="icon-arrowLeft"></span></span></a></li>
        </ul>
    </div>
    <form action="index.php" method="post" enctype="multipart/form-data">
        <table width="100%" border="1" cellpadding="5" cellspacing="0"
            bgcolor="#ABCDEF" align="center">
            <tr id="createFolder" style="display: none;">
                <td>請輸入文件夾名稱</td>
                <td><input type="text" name="dirname" /> <input type="hidden"
                    name="path" value="<?php echo $path;?>" /> <input type="submit"
                    name="act" value="創建文件夾" /></td>
            </tr>
            <tr id="createFile" style="display: none;">
                <td>請輸入文件名稱</td>
                <td><input type="text" name="filename" /> <input type="hidden"
                    name="path" value="<?php echo $path;?>" /> <input type="submit"
                    name="act" value="創建文件" /></td>
            </tr>
            <tr id="uploadFile" style="display: none;">
                <td>請選擇要上傳的文件</td>
                <td><input type="file" name="myFile" /> <input type="submit"
                    name="act" value="上傳文件" /></td>
            </tr>
            <tr>
                <td>編號</td>
                <td>名稱</td>
                <td>類型</td>
                <td>大小</td>
                <td>可讀</td>
                <td>可寫</td>
                <td>可執行</td>
                <td>創建時間</td>
                <td>修改時間</td>
                <td>訪問時間</td>
                <td>操作</td>
            </tr>
        <?php
        $i = 1;
        if (isset ( $arr ) && isset ( $arr ['file'] )) {
            if ($arr ['file']) {
                
                foreach ( $arr ['file'] as $val ) {
                    $p = $path . "/" . $val;
                    ?>
            <tr>
                <td><?php echo $i;?></td>
                <td><?php echo $val;?></td>
                <td><?php $src=filetype($p)=='file'?"file_ico.png":"folder_ico.png";?>
                <img src="images/<?php echo $src;?>" alt="" title="文件" /></td>
                <td><?php echo transByte(filesize($p));?></td>
                <td><?php $src=is_readable($p)?"correct.png":"error.png"?>
            <img src="images/<?php echo $src?>" alt="" class="small" /></td>
                <td><?php $src=is_writeable($p)?"correct.png":"error.png"?>
            <img src="images/<?php echo $src?>" alt="" class="small" /></td>
                <td><img
                    src="images/<?php echo (is_executable($p)? "correct.png":"error.png");?>"
                    alt="" class="small" /></td>
                <td>
            <?php echo date("Y-m-d H:i:s",filectime($p))?>
            </td>
                <td>
            <?php echo date("Y-m-d H:i:s",filemtime($p))?>
            </td>
                <td>
            <?php echo date("Y-m-d H:i:s",fileatime($p))?>
            </td>
            <?php
                    // 得到文件擴展名
                    // explode 將字符串打散為數組
                    // end() 函數將內部指針指向數組中的最后一個元素,并輸出
                    $ext = strtolower ( end ( explode ( ".", $val ) ) );
                    $imageExt = array (
                            "gif",
                            "jpeg",
                            "jpg",
                            "png" 
                    );
                    // in_array() 函數搜索數組中是否存在指定的值。
                    if (in_array ( $ext, $imageExt )) {
                        ?>
                <td><a href="#"
                    onclick="showDetail('<?php echo $val;?>','<?php echo $p;?>')"><img
                        class="small" src="images/show.png" alt="" title="查看" /></a>|
                <?php
                    } else {
                        ?>
            
                
                
                <td><a href="index.php?act=showContent&filename=<?php echo $p?>"><img
                            class="small" src="images/show.png" alt="" title="查看" /></a>|
                <?php
                    }
                    ?>
    
                <a href="index.php?act=editContent&filename=<?php echo $p?>"><img
                            class="small" src="images/edit.png" alt="" title="修改" /></a>| <a
                        href="index.php?act=renameFile&filename=<?php echo $p;?>"><img
                            class="small" src="images/rename.png" alt="" title="重命名" /></a>|
                        <a
                        href="index.php?act=copyFile&path=<?php echo $path;?>&filename=<?php echo $p;?>"><img
                            class="small" src="images/copy.png" alt="" title="復制" /></a>| <a
                        href="index.php?act=cutFile&path=<?php echo $path;?>&filename=<?php echo $p;?>"><img
                            class="small" src="images/cut.png" alt="" title="剪切" /></a>| <a
                        href="" onclick="return delFile('<?php echo $p;?>')"><img
                            class="small" src="images/delete.png" alt="" title="刪除" /></a>| <a
                        href="index.php?act=downFile&filename=<?php echo $p?>"><img
                            class="small" src="images/download.png" alt="" title="下載" /></a></td>
            
            </tr>
            
            
        <?php
                    $i ++;
                }
            } else {
                // echo "<script type='text/javascript'>alert('沒有文件!');</script>";
            }
        }
        ?>
        
        <!-- 讀取目錄的操作 -->
        <?php
        if (isset ( $arr ['dir'] )) {
            if ($arr ['dir']) {
                foreach ( $arr ['dir'] as $val ) {
                    $p = $path . "/" . $val;
                    ?>
            <tr>
                <td><?php echo $i;?></td>
                <td><?php echo $val;?></td>
                <td><?php $src=filetype($p)=='file'?"file_ico.png":"folder_ico.png";?>
                <img src="images/<?php echo $src;?>" alt="" title="文件" /></td>
                <td><?php $sum=0;echo transByte(dirSize($p));?></td>
                <td><?php $src=is_readable($p)?"correct.png":"error.png"?>
            <img src="images/<?php echo $src?>" alt="" class="small" /></td>
                <td><?php $src=is_writeable($p)?"correct.png":"error.png"?>
            <img src="images/<?php echo $src?>" alt="" class="small" /></td>
                <td><img
                    src="images/<?php echo (is_executable($p)? "correct.png":"error.png");?>"
                    alt="" class="small" /></td>
                <td>
            <?php echo date("Y-m-d H:i:s",filectime($p))?>
            </td>
                <td>
            <?php echo date("Y-m-d H:i:s",filemtime($p))?>
            </td>
                <td>
            <?php echo date("Y-m-d H:i:s",fileatime($p))?>
            </td>
                <td><a href="index.php?path=<?php echo $p;?>"><img class="small"
                        src="images/show.png" alt="" title="查看" /></a>| <a
                    href="index.php?act=renameFolder&path=<?php echo $path;?>&dirname=<?php echo $p;?>"><img
                        class="small" src="images/rename.png" alt="" title="重命名" /></a>| <a
                    href="index.php?act=copyFolder&path=<?php echo $path;?>&dirname=<?php echo $p;?>">
                        ![](images/copy.png)
                </a>| <a
                    href="index.php?act=cutFolder&path=<?php echo $path;?>&dirname=<?php echo $p;?>"><img
                        class="small" src="images/cut.png" alt="" title="剪切" /></a>| <a
                    href=""
                    onclick="return delFolder('<?php echo $p;?>','<?php echo $path?>')"><img
                        class="small" src="images/delete.png" alt="" title="刪除" /></a>| <a
                    href="index.php?act=downFile&filename=<?php echo $p?>"><img
                        class="small" src="images/download.png" alt="" title="下載" /></a></td>

            </tr>
            
            
        <?php
                    $i ++;
                }
            } else {
                // echo "<script type='text/javascript'>alert('沒有目錄!');</script>";
            }
        }
        
        ?>
    </table>
    </form>
</body>
</html>
Paste_Image.png
最后編輯于
?著作權歸作者所有,轉載或內容合作請聯系作者
平臺聲明:文章內容(如有圖片或視頻亦包括在內)由作者上傳并發布,文章內容僅代表作者本人觀點,簡書系信息發布平臺,僅提供信息存儲服務。
  • 序言:七十年代末,一起剝皮案震驚了整個濱河市,隨后出現的幾起案子,更是在濱河造成了極大的恐慌,老刑警劉巖,帶你破解...
    沈念sama閱讀 228,936評論 6 535
  • 序言:濱河連續發生了三起死亡事件,死亡現場離奇詭異,居然都是意外死亡,警方通過查閱死者的電腦和手機,發現死者居然都...
    沈念sama閱讀 98,744評論 3 421
  • 文/潘曉璐 我一進店門,熙熙樓的掌柜王于貴愁眉苦臉地迎上來,“玉大人,你說我怎么就攤上這事。” “怎么了?”我有些...
    開封第一講書人閱讀 176,879評論 0 381
  • 文/不壞的土叔 我叫張陵,是天一觀的道長。 經常有香客問我,道長,這世上最難降的妖魔是什么? 我笑而不...
    開封第一講書人閱讀 63,181評論 1 315
  • 正文 為了忘掉前任,我火速辦了婚禮,結果婚禮上,老公的妹妹穿的比我還像新娘。我一直安慰自己,他們只是感情好,可當我...
    茶點故事閱讀 71,935評論 6 410
  • 文/花漫 我一把揭開白布。 她就那樣靜靜地躺著,像睡著了一般。 火紅的嫁衣襯著肌膚如雪。 梳的紋絲不亂的頭發上,一...
    開封第一講書人閱讀 55,325評論 1 324
  • 那天,我揣著相機與錄音,去河邊找鬼。 笑死,一個胖子當著我的面吹牛,可吹牛的內容都是我干的。 我是一名探鬼主播,決...
    沈念sama閱讀 43,384評論 3 443
  • 文/蒼蘭香墨 我猛地睜開眼,長吁一口氣:“原來是場噩夢啊……” “哼!你這毒婦竟也來了?” 一聲冷哼從身側響起,我...
    開封第一講書人閱讀 42,534評論 0 289
  • 序言:老撾萬榮一對情侶失蹤,失蹤者是張志新(化名)和其女友劉穎,沒想到半個月后,有當地人在樹林里發現了一具尸體,經...
    沈念sama閱讀 49,084評論 1 335
  • 正文 獨居荒郊野嶺守林人離奇死亡,尸身上長有42處帶血的膿包…… 初始之章·張勛 以下內容為張勛視角 年9月15日...
    茶點故事閱讀 40,892評論 3 356
  • 正文 我和宋清朗相戀三年,在試婚紗的時候發現自己被綠了。 大學時的朋友給我發了我未婚夫和他白月光在一起吃飯的照片。...
    茶點故事閱讀 43,067評論 1 371
  • 序言:一個原本活蹦亂跳的男人離奇死亡,死狀恐怖,靈堂內的尸體忽然破棺而出,到底是詐尸還是另有隱情,我是刑警寧澤,帶...
    沈念sama閱讀 38,623評論 5 362
  • 正文 年R本政府宣布,位于F島的核電站,受9級特大地震影響,放射性物質發生泄漏。R本人自食惡果不足惜,卻給世界環境...
    茶點故事閱讀 44,322評論 3 347
  • 文/蒙蒙 一、第九天 我趴在偏房一處隱蔽的房頂上張望。 院中可真熱鬧,春花似錦、人聲如沸。這莊子的主人今日做“春日...
    開封第一講書人閱讀 34,735評論 0 27
  • 文/蒼蘭香墨 我抬頭看了看天上的太陽。三九已至,卻和暖如春,著一層夾襖步出監牢的瞬間,已是汗流浹背。 一陣腳步聲響...
    開封第一講書人閱讀 35,990評論 1 289
  • 我被黑心中介騙來泰國打工, 沒想到剛下飛機就差點兒被人妖公主榨干…… 1. 我叫王不留,地道東北人。 一個月前我還...
    沈念sama閱讀 51,800評論 3 395
  • 正文 我出身青樓,卻偏偏與公主長得像,于是被迫代替她去往敵國和親。 傳聞我的和親對象是個殘疾皇子,可洞房花燭夜當晚...
    茶點故事閱讀 48,084評論 2 375

推薦閱讀更多精彩內容