3
votes

Okay, here's the rundown.

I'm developing a video hosting site with PHP and jQuery primarily. My client is absolutely set on using Filezilla to upload his videos via FTP instead of allowing me to handle the upload directly with PHP. This makes me mildly psychotic, but hey, the money man calls the shots.

Since I have no way of detecting the completion of those FTP uploads, I set him up with a special FTP account that is rooted into the uploads directory, and designed an interface that monitors that folder and allows him to start transcoding those files for web at his discretion. This is less than optimal. I'd like to show the progress of currently processing uploads on my mobile app, and hopefully start encoding files automatically when the FTP transfer completes.

So what I'm really asking for is either a method of detecting that a file is still being uploaded, or some way of finding the size of the original file that is being uploaded so that I can do comparisons.

Thanks!

2
What OS is this all on? On Unix, you can use fuser to see if a file is currently in use by a process, which'd mean that it's probably still being uploaded. - Marc B
I'm on Ubuntu 11.04. I'll look into this, thanks! - MacKinley Smith
@MarcB Okay great, I'm pretty sure I could detect currently processing uploads using fuser, this is good news as I should be able to automatically start the transcode process when the upload completes now. The full size of the file would still be monumentally helpful for another purpose, with the mobile app showing progress so that he can monitor it remotely. Thanks again! - MacKinley Smith
You could also look into inotify which works at the kernel level to watch for file changes. It'd be more reliable than a timed-job checking for file changes - you'll get realtime notifications as events occur. - Marc B
@MarcB This is even better for that purpose. If you put these in an answer, I will vote up. - MacKinley Smith

2 Answers

4
votes

On Linux, you can use fuser to see if a file's in use by a process. A more reliable option would be to use the inotify system, which'll give you realtime notifications of file change events.

1
votes

In case anyone else is ever wondering, the answer to the question reached through the comments and more research on my end to confirm, is that the total size of a file is not passed to the server at all during ftp transfers. Thanks to Jonathan Amend.