Jump to content


Photo

Set a variable when download start


  • Please log in to reply
5 replies to this topic

#1 habeebnet

habeebnet
  • New Members
  • Pip
  • Newbie
  • 1 posts

Posted 18 August 2006 - 04:26 PM

Here's my file download script....
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 * 8);				
       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-

#2 Caesar

Caesar
  • Members
  • PipPipPip
  • Advanced Member
  • 1,025 posts

Posted 18 August 2006 - 08:58 PM

I'm looking for a way to set a variable (say $status=TRUE) TRUE when somebody clicks on save button.


Javascript is your friend. ;-)
PHP Ninja

#3 corbin

corbin
  • Staff Alumni
  • Advanced Member
  • 8,129 posts

Posted 18 August 2006 - 09:00 PM

A javascript variable and a php variable arent accessible to each other though... From what I understand youre tryin to do, Im not sure if its impossible or not but ive never seen it happen...
Why doesn't anyone ever say hi, hey, or whad up world?

#4 tomfmason

tomfmason
  • Staff Alumni
  • Advanced Member
  • 1,696 posts
  • Locationstealing your wifi

Posted 18 August 2006 - 09:04 PM

I agree. I have not seen this. I wish this were possible. I am interested in doing this my self.

Traveling East in search of instruction, and West to propagate the knowledge I have had gained.

current projects: pokersource

My Blog | My Pastebin | PHP Validation class | Backtrack linux


#5 corbin

corbin
  • Staff Alumni
  • Advanced Member
  • 8,129 posts

Posted 18 August 2006 - 09:08 PM

Hmm now that i think about it... It probably is impossible... Since a webserver has no way of knowing if your web client is downloading anything... Hmm but wait... maybe it does know since its a constant connection...  Seems like it would almost take a packet sniffer lol... As far as I know its not a php function or anything... But I'm sure its possible...
Why doesn't anyone ever say hi, hey, or whad up world?

#6 ryanlwh

ryanlwh
  • Staff Alumni
  • Advanced Member
  • 511 posts

Posted 18 August 2006 - 10:22 PM

while you can't possibly set a variabe within the same script from javascript, you can, however, use AJAX or set a cookie with javascript. but i haven't seen any javacript code to listen to file download dialogs, and if you output the javascript in this same script, it will be treated as the text content of the file... maybe use frames.

as far as i know, jsp might be able to sniff packets :)
Please use EDIT * 100...
Please use
or [php] * 1000...

PLEASE READ THE POSTED SOLUTIONS CAREFULLY * 1000000...




0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users