Skip to content
Advertisement

Unlink tempnam throws error “Resource temporarily unavailable”

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

Warning Error: unlink(“my file path”TempTMPAF91.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.

Advertisement

Answer

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).

User contributions licensed under: CC BY-SA
6 People found this is helpful
Advertisement