2 回答

TA貢獻(xiàn)1898條經(jīng)驗 獲得超8個贊
tmp 在執(zhí)行的地方是否存在?tmpfileee 是您要創(chuàng)建的文件或目錄嗎?如果 tmp 不存在并且 tmpfileee 也不存在,我相信您正在嘗試在調(diào)用中創(chuàng)建 2 個沒有遞歸參數(shù)的目錄。
我的 PHP 肯定生銹了,所以也許其他人可以回答得更好,但這只是我最初的想法。

TA貢獻(xiàn)1848條經(jīng)驗 獲得超10個贊
就這樣試試:
if (!file_exists('tmp/tmpfileeee') AND !is_dir('tmp/tmpfileeee')) {
mkdir('tmp/tmpfileeee',0755, true);
echo 'created';
}
mkdir創(chuàng)建一個文件夾而不是 file。
如果要創(chuàng)建文件:
if (!file_exists('tmp/tmpfileeee') AND !is_file('tmp/tmpfileeee')) {
$fp = fopen('tmp/tmpfileeee', 'w');
echo 'created';
}
或最佳方式:
// 1. Check folder and xreate if not exists
if (!file_exists('tmp') AND !is_dir('tmp')) {
mkdir('tmp',0755, true);
echo 'folder created';
}
// 2. Check file and create if not exists
if (!file_exists('tmp/tmpfileeee') AND !is_file('tmp/tmpfileeee')) {
$fp = fopen('tmp/tmpfileeee', 'w');
echo 'file created';
}
更新
在某些服務(wù)器上,tmp和temp文件夾受到限制。
檢查open_basedir.
PHP手冊指出:
如果此處指定的目錄不可寫,PHP 會回退到系統(tǒng)默認(rèn)的臨時目錄。如果打開了 open_basedir,則必須允許系統(tǒng)默認(rèn)目錄才能成功上傳。
- 2 回答
- 0 關(guān)注
- 269 瀏覽
添加回答
舉報