PHP之檔案系統處理 檔案的屬

2021-06-17 23:12:07 字數 1342 閱讀 4467

php之檔案系統處理_檔案的屬性

讓拖鞋再飛一會兒

1.2 檔案的屬性

php的檔案屬性處理函式

函式名 

作用 返回值

file_exists() 

檢測檔案或目錄是否存在 

true/false

filesize() 

取得檔案大小 

位元組數is_readable() 

判斷檔案是否可讀 

true/false

is_writable() 

判斷檔案是否可寫 

true/false

is_executable() 

判斷檔案是否為可執行檔案 

true/false

filectime() 

取得檔案建立時間 

返回unix時間戳格式

filemtime() 

取得檔案修改時間 

返回unix時間戳格式

fileatime() 

取得檔案上次訪問時間 

返回unix時間戳格式

stat() 

獲取檔案大部分屬性值 

返回關於給定檔案有用資訊數值

cleartatcache() 

清除被php快取的檔案資訊

<?php

// 要實現的功能:判斷檔案型別(是目錄或者檔案,建立時間,檔案屬性,大小)

date_default_timezone_set("prc"); //將時區轉為中國時區

function getfilepro($filename)elseif(is_file($filename))

if(is_writable($filename))

if(is_executable($filename))

echo "檔案建立的時間 :".date("y-m-d h:i:s",filectime($filename))."

";echo "檔案上次修改的時間 :".date("y-m-d h:i:s",filemtime($filename))."

"; echo "檔案上次訪問的時間 :".date("y-m-d h:i:s",fileatime($filename))."

"; }else

}function getfilesize($size)elseif($size>=pow(2,30))elseif($size>=pow(2,20))elseif($size>=pow(2,10))else

return $size.$dw;

}getfilepro("post.php");

getfilepro("test");

?>

PHP之檔案系統處理 檔案上傳處理

bool is uploaded file string name 用於判斷指定的檔案是否通過httppost上傳的。filename必須類似於 files filename temp name 的變數,不可以使用從客戶端上傳的檔名 files filename name move upload f...

PHP之檔案系統處理 檔案操作

php之檔案系統處理 檔案操作相關的函式三 讓拖鞋再飛一會兒 目錄操作相關函式 函式名 作用 使用方法 opendir 開啟目錄控制代碼 resource opendir string path resource context readdir 從目錄控制代碼中讀取條目 string readdir...

PHP之檔案系統處理 Filesystem

filesystem 函式 basename 返回路徑中的檔名部分 chgrp 改變檔案所屬的組 chmod 改變檔案模式 chown 改變檔案的所有者 clearstatcache 清除檔案狀態快取 copy 拷貝檔案 delete 參見 unlink 或 unset dirname 返回路徑中的...