我遇到过一些使用 Bluehost 安装 WordPress 的案例。由于上传文件夹 wp-content/uploads
不存在,我的 WordPress 主题遇到错误。
显然是 Bluehost cPanel WordPress 安装程序不会创建此文件夹,但 HostGator可以。
所以我需要向我的主题添加代码,以检查文件夹并以其他方式创建它。
最佳答案
试试这个,使用 mkdir :
if (!file_exists('path/to/directory')) {
mkdir('path/to/directory', 0777, true);
}
请注意,0777
已经是目录的默认模式,可能仍会被当前的 umask 修改。
https://stackoverflow.com/questions/2303372/