首頁  >  問答  >  主體

“取消連結 tempnam 時出現暫時不可用錯誤”

我想取消連結(刪除)我的臨時文件,但 php 拋出錯誤:

警告錯誤:取消連結(「我的檔案路徑」\Temp\TMPAF91.tmp):[「我的檔案路徑」\myscript 中的資源暫時不可用.php,行“數字”]

#
$tmpfile = tempnam(sys_get_temp_dir(), 'zipfile');

file_put_contents($tmpfile, $content);

$zip = new ZipArchive;

if ($zip->open($tmpfile) === true) {
// my code in here to extract the $content of the $tmpfile

  $zip->close();
} 



unlink($tmpfile);

我不確定這裡發生了什麼事。 ZipArchive 已關閉,所以我肯定應該被允許取消連結。

P粉309989673P粉309989673178 天前265

全部回覆(1)我來回復

  • P粉085689707

    P粉0856897072024-03-29 00:00:21

    此錯誤僅發生在我的 Windows 電腦上(Mamp 設定中的版本 10)。

    在我的 Linux 伺服器上(Debian Jessie 發行版)。這工作得很好。

    它在我的 Mac 上也能正常工作(Mamp 設定中的 Catalina)。

    回覆
    0
  • 取消回覆