首页  >  问答  >  正文

“取消链接 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 天前269

全部回复(1)我来回复

  • P粉085689707

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

    此错误仅发生在我的 Windows 计算机上(Mamp 设置中的版本 10)。

    在我的 Linux 服务器上(Debian Jessie 发行版)。这工作得很好。

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

    回复
    0
  • 取消回复