php how to test if file has been uploaded completely

后端 未结 11 1562
耶瑟儿~
耶瑟儿~ 2021-02-01 15:24

Is there any way to check if file has been uploaded completely on the server? My scenario: User uploads file over ftp and my other PHP task is running in cronjob. Now I would li

11条回答
  •  长发绾君心
    2021-02-01 16:15

    you can set a thread to get details using : ll -h

    and getting the size column and comparing it after a certain time interval if it stays the same for 2 or 3 time interval then the upload could be finished.

    if you need a more precise solution and if you are looking for a more complicated way (but efficient) to do it, check this out :

    http://www.php.net/manual/en/function.inotify-read.php

    You can take a look at this example in the link I gave, You will need to check for the event code IN_CLOSE_WRITE

    Taken from : LINUX: how to detect that ftp file upload is finished

提交回复
热议问题