Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Detect with php if files is being uploaded, or is open

Tags:

php

I have a PHP script that opens a local directory in order to copy and process some files. But these files may be incomplete, because they are being uploaded by a slow FTP process, and I do not want to copy or process any files which have not been completely uploaded yet.

Is is possible in PHP to find out if a file is still being copied (that is, read from), or written to?

I need my script to process only those files that have been completely uploaded.

The ftp process now, upload files in parallel, and it take more than 1 second for each filesize to change, so this trick is not working for me now, any other method suggests

like image 552
albanx Avatar asked Jan 14 '11 16:01

albanx


People also ask

How can I check if a file is uploaded in PHP?

The is_uploaded_file() function in PHP is an inbuilt function which is used to check whether the specified file uploaded via HTTP POST or not. The name of the file is sent as a parameter to the is_uploaded_file() function and it returns True if the file is uploaded via HTTP POST.

Which function is used to determine whether a file was uploaded in PHP?

The is_uploaded_file() function checks whether the specified file is uploaded via HTTP POST.

What is Move_uploaded_file in PHP?

Definition and Usage. The move_uploaded_file() function moves an uploaded file to a new destination. Note: This function only works on files uploaded via PHP's HTTP POST upload mechanism. Note: If the destination file already exists, it will be overwritten.


1 Answers

Do you have script control over the FTP process? If so, have the script that's doing the uploading upload a [FILENAME].complete file (blank text file) after the primary upload completes, so the processing script knows that the file is complete if there's a matching *.complete file there also.

like image 151
MidnightLightning Avatar answered Sep 30 '22 15:09

MidnightLightning