0

i have tried serval ways for how to detect if file is not yet complete and is still being copied. but

    $filemtimeNOW   =   date("F d Y H:i:s.", filemtime($tempPath."files/". "test.csv"));
    sleep(20);
    $filemtimeLATER =   date("F d Y H:i:s.", filemtime($tempPath."files/". "test.csv"));
    echo   $filemtimeNOW . "<br>";
    echo   $filemtimeLATER . "<br>";
    sleep(10);
        if ($filemtimeNOW  == $filemtimeLATER)
        echo   $filemtimeNOW. "finished" ;
        else 
        echo   $filemtimeNOW. "still being copied" ;

RESTULT IS

1449338332 1449338332 1449338332 finished

even if the file is still uploading via ftp it shows the total filesize i have also tried with datetime and still same problem hopesomeone have idea

inventor
  • 55
  • 2
  • 3
  • 10

1 Answers1

1

You can try with filesize, not testes :

$filesizeNOW   =   filesize($tempPath."files/". "test.csv");
sleep(20);
$filesizeLATER =   filesize($tempPath."files/". "test.csv");
echo   $filesizeNOW . "<br>";
echo   $filesizeLATER . "<br>";
sleep(10);
    if ($filesizeNOW  == $filesizeLATER)
    echo   $filesizeNOW. "finished" ;
    else 
    echo   $filesizeNOW. "still being copied" ;
Raphaël Vigée
  • 2,048
  • 14
  • 27
  • I have just tried Warning: filesize(): stat failed for /home/..../test.csv in /home/.../scrap.php on line 21 January 01 1970 01:00:00. January 01 1970 01:00:00. January 01 1970 01:00:00.finished – inventor Dec 05 '15 at 19:22
  • done and the same December 05 2015 20:25:14. December 05 2015 20:25:14. December 05 2015 20:25:14.finished – inventor Dec 05 '15 at 19:26
  • strange becouse i can see that when uploading the file it is increasing in the filezilla but ow to get the modified date in realtime or something – inventor Dec 05 '15 at 19:27
  • Why do the code returns you a date as `filesize` returns an int ? – Raphaël Vigée Dec 05 '15 at 19:27
  • Now i removed the date from the function and got 14929056 14929056 14929056finished – inventor Dec 05 '15 at 19:29
  • i just want a way to know if the file is complete before i can use it. becouse if it is not completly uploaded i will have a problem – inventor Dec 05 '15 at 19:33