Forum Moderators: coopster

Message Too Old, No Replies

Determine if file is complete

         

wesg

1:04 am on Jul 23, 2008 (gmt 0)

10+ Year Member



I've made a page on my website that simply lists the files in the directory so that it is easy for people to download. It consists of a PHP script reading the directory and making an array of files that aren't set to be excluded (stylesheets, index, etc.)

The files are displayed in a table that shows the filename, as well as the filesize.

My problem is that when I'm uploading files to the directory, people browsing the page see the file, but it is incomplete. Is there some way to hide files are not yet finished uploading?

eelixduppy

4:31 am on Jul 23, 2008 (gmt 0)



Not sure how you are uploading the files to your server, however, if it is through a script then in the beginning I would write the file name (with the path) to a temporary file that contains the names of all files being uploaded at the time. These files are to be excluded as well from the directory listing. Upon upload completion, delete the name from the temp file.

This is a quick solution I just came up with and may not be the best. But it should work if implemented correctly.

vincevincevince

4:50 am on Jul 23, 2008 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



Other similar approaches:
1. Upload new files to a different directory, when upload is complete, have your script move the file
2. If you are using FTP, use a client which uploads under a modified name then renames when complete (good ones do this). Typically they will upload 'file.txt' as '~file.txt' or 'file.txt.part', and rename only when done. Have your PHP script miss out files starting with ~ or ending in .part as applicable.

eelixduppy

5:02 am on Jul 23, 2008 (gmt 0)



Nice ideas, vince, I like them :)

wesg

1:06 am on Jul 25, 2008 (gmt 0)

10+ Year Member



Ah yes, Vince,
those ideas sound best. I will take a look. Thanks!