keep surfing while forcing a download

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
prima-nocte
Forum Newbie
Posts: 9
Joined: Tue Oct 04, 2005 7:28 am

keep surfing while forcing a download

Post by prima-nocte »

the title isn't very clear i admit that but didn't know a nice and snappy title ;)

I have a membersection on my website where people can download movies.
I serve these movies with:

Code: Select all

header("Cache-control: private");
header("Content-type: application/x-download");
header("Content-Disposition: attachment; filename=$downloadmovie;");
header("Accept-Ranges: bytes");
header("Content-Length: $download_size");
readfile($file_server_path);
no problems. all works fine. But while you are downloading you can't surf further on the website. The movies are about 500 Mb each so i would like it for our customers that they can proceed navigating our website while downloading the movie in the background. Or at least have two downloads at the same time.

Anybody have any idea why the website stops while downloading? As soon as i cancel the download the website loads fine again. But while downloading a movie everything stops.
Thanks
User avatar
feyd
Neighborhood Spidermoddy
Posts: 31559
Joined: Mon Mar 29, 2004 3:24 pm
Location: Bothell, Washington, USA

Post by feyd »

I believe most often this is more due to an individual's browser.. but it can be affected by how you initiate the download.. for instance, in a popup or something..
prima-nocte
Forum Newbie
Posts: 9
Joined: Tue Oct 04, 2005 7:28 am

Post by prima-nocte »

i tried opening the page in different browsers and in a _blank window and with window.open.. everything.. but still nothing.

Does the php process stay alive while downloading? or does he just serves the file and then backs off?
User avatar
feyd
Neighborhood Spidermoddy
Posts: 31559
Joined: Mon Mar 29, 2004 3:24 pm
Location: Bothell, Washington, USA

Post by feyd »

the thread/process stays active for as long as is needed to load and send the entire file.
prima-nocte
Forum Newbie
Posts: 9
Joined: Tue Oct 04, 2005 7:28 am

Post by prima-nocte »

damn.. that aint good :s.. is there any other way of serving protected files where the php proces doesn't stay active while downloading that you're aware of?
All the files are in a htaccess protected folder so i need to serve them with php.. but this is not so good...
User avatar
feyd
Neighborhood Spidermoddy
Posts: 31559
Joined: Mon Mar 29, 2004 3:24 pm
Location: Bothell, Washington, USA

Post by feyd »

your web server can run mutliple instances of php concurrently.. otherwise only one person could be looking at a page at any given, which is quite useless for a web server now isn't it? ;)

It may be a host configured thing that is outside your control. For instance, maybe they set a limit as to how much a particular visitor can occupy the CPU, or that they only allow a visitor to request from one page at a time..
prima-nocte
Forum Newbie
Posts: 9
Joined: Tue Oct 04, 2005 7:28 am

Post by prima-nocte »

any idea what that setting might be? ;) .. i have full control over te server so i should be able to alter it
Post Reply