How to determine whether a file is still being transferred via ftp

后端 未结 5 1549
情书的邮戳
情书的邮戳 2020-12-06 15:59

I have a directory with files that need processing in a batch with PHP. The files are copied on the server via FTP. Some of the files are very big and take a long time to co

5条回答
  •  执念已碎
    2020-12-06 16:41

    It's not realy nice trick, but it's simple :-), the same u can do with filemtime

    $result = false;
    $tryies = 5;
    if (file_exists($filepath)) {
        for ($i=0; $i < $tryies; $i++) { 
            sleep(1);
            $filesize[] = filesize($filepath);
        }
        $filesize = array_unique($filesize);
        if (count($filesize) == 1) {
            $result = true;
        } else {
            $result = false;
        }
    }
    
    return $result;
    

提交回复
热议问题