Forum Moderators: phranque

Message Too Old, No Replies

Renaming a file during download on Apache

         

unspoken

10:07 pm on Jun 4, 2009 (gmt 0)

10+ Year Member



Please imagine this: I am starting to download a file on my web server "/download1/testfile.zip" (its size is about 150 mb). While I am downloading it (directly from apache server), I am renaming the file path "/download1/testfile.zip" to "/download2/testfile.zip" with php and the download is not getting interrupted.

1) Why can I rename it while I am downloading it. Is not that is file which is in use?
2) If I can rename it, why the download is not getting interrupted?

I am using Linux CentOS, Apache 2.2.11, PHP 5.2.5

g1smd

11:20 pm on Jun 4, 2009 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member Top Contributors Of The Month



In Windows (and probably true for other OS such as yours), the file is actually downloaded to a hidden temporary location with a random filename and then only when the download is complete is it copied over to the location you specified and given the name that you wanted.

jdMorgan

11:38 pm on Jun 4, 2009 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



Because the entire file likely got sucked into a temporary buffer for transmission, before your rename was invoked. Or perhaps it's being cached by the server or the OS, and the "file read" operation is being permitted to complete despite the rename.

Jim