dhillarun Posted March 6, 2007 Share Posted March 6, 2007 Hi , I am using the following script to enable download. How to track whether "cancel" button clicked and download is not complete? Pl do reply me. function download($inline = false) { $user_agent = (isset($_SERVER["HTTP_USER_AGENT"]) ) ? $_SERVER["HTTP_USER_AGENT"] : $HTTP_USER_AGENT; while (@ob_end_clean()); $fsize = filesize($this->path.$this->name); $mod_date = date('r', filemtime( $this->path.$this->name ) ); $cont_dis = $inline ? 'inline' : 'attachment'; header("Pragma: public"); header("Cache-Control: must-revalidate, post-check=0, pre-check=0"); header("Expires: 0"); header("Content-Transfer-Encoding: binary"); header('Content-Disposition:' . $cont_dis .';' . ' filename="' . $this->name . '";' . ' modification-date="' . $mod_date . '";' . ' size=' . $fsize .';' ); //RFC2183 header("Content-Type: " . $this->mime ); // MIME type header("Content-Length: " . $fsize); // No encoding - we aren't using compression... (RFC1945) //header("Content-Encoding: none"); //header("Vary: none"); $this->request = date("Y-m-d H:i:s", time("Y-m-d g:i:s")); $this->status = $this->readfile_chunked($this->path.$this->name); $this->response = date("Y-m-d H:i:s", time("Y-m-d g:i:s")); } function readfile_chunked($filename,$retbytes=true) { $chunksize = 1*(1024*1024); // how many bytes per chunk $buffer = ''; $cnt =0; $handle = fopen($filename, 'rb'); if ($handle === false) { return false; } while (!feof($handle)) { $buffer = fread($handle, $chunksize); echo $buffer; //sleep(100); if ($retbytes) { $cnt += strlen($buffer); } } $this->dsize=$cnt; $status = fclose($handle); if ($retbytes && $status) { return $cnt; // return num. bytes delivered like readfile() does. } return $status; } Quote Link to comment Share on other sites More sharing options...
dhillarun Posted March 6, 2007 Author Share Posted March 6, 2007 If we display save(download) dialogeue box, how to know whether user clicked save button or cancel button. I want to know , how to get that info. Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.