Unlink tempnam throws error "Resource temporarily unavailable"

Viewed 96

I want to unlink (delete) my temporary file but php throws the error :

Warning Error: unlink("my file path"\Temp\TMPAF91.tmp): Resource temporarily unavailable in ["my file path"\myscript.php, line "number"]

$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);

I'm not sure what's happening here. The ZipArchive is closed so surely I should be allowed to unlink it.

1 Answers

This error only occurs on my Windows machine (ver. 10 in a Mamp setup).

On my Linux server (distr. Debian Jessie). This works fine.

It also works fine on my Mac (Catalina in a Mamp setup).

Related