15,024
edits
(→檔案操作有關) |
m (→檔案操作有關) |
||
| Line 6: | Line 6: | ||
* 檢查檔案或目錄是否存在 [http://tw2.php.net/file_exists file_exists] | * 檢查檔案或目錄是否存在 [http://tw2.php.net/file_exists file_exists] | ||
* 如果是上傳檔案,需要檢查暫存目錄是否可以寫入 [http://stackoverflow.com/questions/1520956/php-way-to-find-the-web-servers-temp-path upload - PHP way to find the web server's temp path? - Stack Overflow] | * 如果是上傳檔案,需要檢查暫存目錄是否可以寫入 [http://stackoverflow.com/questions/1520956/php-way-to-find-the-web-servers-temp-path upload - PHP way to find the web server's temp path? - Stack Overflow] | ||
* 檢查該檔案所在該目錄是否已經建立,若未建立則需要建立 [http://php.net/manual/en/function.mkdir.php mkdir],並設定可以寫入。如果產生位置是在多層子目錄下 (巢狀的多層目錄),則需要啟用 | * 檢查該檔案所在該目錄是否已經建立,若未建立則需要建立 [http://php.net/manual/en/function.mkdir.php mkdir],並設定可以寫入。如果產生位置是在多層子目錄下 (巢狀的多層目錄),則需要啟用 recursive <ref>[http://stackoverflow.com/questions/2303372/create-a-folder-if-it-doesnt-already-exist php - Create a folder if it doesn't already exist - Stack Overflow] code snippet: <nowiki>mkdir('path/to/directory', 0755, true);</nowiki> </ref> | ||
* 檢查該檔案/目錄是否可以寫入 | * 檢查該檔案/目錄是否可以寫入 | ||
** [http://php.net/manual/en/function.is-writable.php is_writable]: 如果要刪除檔案,需要檢查是否可以寫入 | ** [http://php.net/manual/en/function.is-writable.php is_writable]: 如果要刪除檔案,需要檢查是否可以寫入 | ||