Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/php/277.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
PHP强制关闭一个文件,即使它在另一个进程中使用_Php_Windows_Unlink - Fatal编程技术网

PHP强制关闭一个文件,即使它在另一个进程中使用

PHP强制关闭一个文件,即使它在另一个进程中使用,php,windows,unlink,Php,Windows,Unlink,我有一个压缩PDF文件的API。当API失败时,我需要取消该文件的链接,并出现“权限被拒绝”错误。如何强制关闭一个文件,即使它在另一个进程中使用?。我正在使用Windows平台 if(move_uploaded_file($_FILES['researchfile']['tmp_name'], $target_path1)) { /** Call API to compress PDF **/ $API_response = compress_now($target_path1)

我有一个压缩PDF文件的API。当API失败时,我需要取消该文件的链接,并出现“权限被拒绝”错误。如何强制关闭一个文件,即使它在另一个进程中使用?。我正在使用Windows平台

if(move_uploaded_file($_FILES['researchfile']['tmp_name'], $target_path1))
{
    /** Call API to compress PDF **/
    $API_response = compress_now($target_path1);
    /** compress failed.File is still in use **/
    if(isset($API_response->error))
    {          
     unlink($target_path1);/** Couldnot unlink.Permission denied  **/
    } 
}

请解释你的问题,并告诉我们你是如何试图实现的。我附上了我的代码片段@Siddiqui您的文件的权限是什么?这与权限无关。我需要关闭一个已在使用的文件