Setting a variable while downloading

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
habeebnet
Forum Newbie
Posts: 1
Joined: Fri Aug 18, 2006 11:08 am

Setting a variable while downloading

Post by habeebnet »

feyd | Please use

Code: Select all

,

Code: Select all

and [syntax="..."] tags where appropriate when posting code. Your post has been edited to reflect how we'd like it posted. Please read:  [url=http://forums.devnetwork.net/viewtopic.php?t=21171]Posting Code in the Forums[/url] to learn how to do it too.[/color]


Here's my file download script....

Code: Select all

set_time_limit(0);
$speed = 10;

header("Cache-control: private");
header('Content-Description: File Transfer'); 
header('Content-Type: application/force-download');	
header('Content-Length: ' . filesize($fileLocation . $fileName));	
header('Content-Disposition: attachment; filename=' . $fileName);

if (!$file = fopen($fileLocation . $fileName, 'r')) {
      exit();
}

while (!feof($file)) {			
       echo fread($file, $speed * 1024 * ;				
       flush();
       sleep(1);
}
when this script runs, a file dialogue box will appear with a 'save' and 'cancel' button.. I'm looking for a way to set a variable (say $status=TRUE) TRUE when somebody clicks on save button. And when downlaods completes, the variable should set to FALSE.

I trying to implement this for the last two days... but always the variable will set to to TRUE before i click 'Save'..

Can anybody help me?

Many Thanks
-Hab-


feyd | Please use

Code: Select all

,

Code: Select all

and [syntax="..."] tags where appropriate when posting code. Your post has been edited to reflect how we'd like it posted. Please read:  [url=http://forums.devnetwork.net/viewtopic.php?t=21171]Posting Code in the Forums[/url] to learn how to do it too.[/color]
User avatar
feyd
Neighborhood Spidermoddy
Posts: 31559
Joined: Mon Mar 29, 2004 3:24 pm
Location: Bothell, Washington, USA

Post by feyd »

PHP doesn't pause the execution to wait for the user to click save or not. You may want to look at connection_aborted() and its siblings however.
Post Reply