必要時建立資料夾
必要時建立資料夾在某些情況下,特別是在Bluehost 上安裝WordPress 時,上傳資料夾(wp- content/uploads) 可能會缺席,導致錯誤。要解決此問題,最好將程式碼合併到主題中以檢查資料夾是否存在並在必要時建立它。
代碼解決方案if (!file_exists('path/to/directory')) { mkdir('path/to/directory', 0777, true); }
檢查並建立使用mkdir 的資料夾,使用以下程式碼:
if (!file_exists('path/to/ directory')) {
mkdir('路徑/到/目錄', 0777, true);
}
免責聲明: 提供的所有資源部分來自互聯網,如果有侵犯您的版權或其他權益,請說明詳細緣由並提供版權或權益證明然後發到郵箱:[email protected] 我們會在第一時間內為您處理。
Copyright© 2022 湘ICP备2022001581号-3