473,395 Members | 1,468 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,395 software developers and data experts.

"header()"function related question

Hi everybody,

I displaying file download window("save-as dialog box") using PHP "header()" function.

How to track that user have clicked "save" button or "cancel" button???
Mar 12 '07 #1
6 1546
ak1dnar
1,584 Expert 1GB
Hi I don't have a idea about how to trap the click events of the buttons that displays under out side the browser window.
could you please submit the Script that you used for display the save as Dialog box.
Mar 13 '07 #2
Atli
5,058 Expert 4TB
Hi.

I doubt that you can access the download dialog from your scripts.

I would think the browser runs any process, with access to you data, out of reach from any client script.
Mar 13 '07 #3
ronverdonk
4,258 Expert 4TB
Hi.

I doubt that you can access the download dialog from your scripts.

I would think the browser runs any process, with access to you data, out of reach from any client script.
Exactly what I think. The whole download process is executed outside your program control.

Ronald :cool:
Mar 13 '07 #4
Expand|Select|Wrap|Line Numbers
  1.  
  2. function download()
  3. {
  4.  
  5.         header("Pragma: public");
  6.         header("Cache-Control: must-revalidate, post-check=0, pre-check=0");
  7.         header("Expires: 0");
  8.  
  9.         header("Content-Transfer-Encoding: binary");
  10.                 header('Content-Disposition:' . $this->cont_dis .';'
  11.                         . ' filename="' . $this->name . '";'
  12.                         . ' modification-date="' . $this->mod_date . '";'
  13.                         . ' size=' . $this->fsize .';'
  14.                         ); 
  15.         header("Content-Type: "    . $this->mime );                     // MIME type
  16.         header("Content-Length: "  . $this->fsize);
  17.  
  18.  
  19.        $total_bytes=readfile_chunked($this->path.$this->name);
  20. }
  21.  
  22.  function readfile_chunked($filename)
  23.     {
  24.         $chunksize = 1*(1024*1024); // how many bytes per chunk
  25.         $buffer = '';
  26.         $cnt =0;
  27.         $handle = fopen($filename, 'rb');
  28.  
  29.         if ($handle === false)
  30.         {
  31.                 return false;
  32.         }
  33.         while (!feof($handle))
  34.         {
  35.                 $buffer = fread($handle, $chunksize);
  36.                 if(print $buffer)
  37.                 {
  38.                         $cnt += strlen($buffer);
  39.                 }
  40.  
  41.         }
  42.         fclose($handle);
  43.  
  44.         return $cnt; // return num. bytes delivered like readfile() does.
  45.  
  46.     }
  47.  
  48.  
This is the code i am using to display "save-as" dialog box and to send content to the browser.

Actually I am logging every download from my site. So , If the user clicks on "cancel" in the "save-as" dialog box, I should not log it.

Pl provide any sol for this.
Apr 4 '07 #5
ak1dnar
1,584 Expert 1GB
Your script will call to a property (Download-Box) that is completely out side the browser window. so there is no way to trap that click events.

so before you call for the headers you have to trap it. but in that case you can't determine whether the user completely downloaded the file or not only thing you can do by giving to buttons like Accept and Reject you have to trap the events.
Apr 4 '07 #6
Your script will call to a property (Download-Box) that is completely out side the browser window. so there is no way to trap that click events.

so before you call for the headers you have to trap it. but in that case you can't determine whether the user completely downloaded the file or not only thing you can do by giving to buttons like Accept and Reject you have to trap the events.
Accept or Reject buttons will ensure only whether the user wants to download or not. But I wanted to know predict the button clicked in the "Save-As" dialog-box.

Anyway, as per your answer I came to know that, the download dialog-box action is out of our control. So thanks.

Thnx for all your replies.
Apr 5 '07 #7

Sign in to post your reply or Sign up for a free account.

Similar topics

2
by: Stijn Goris | last post by:
Hi all, I have a question regarding the header function. I send a browser to a certain page (eg first.php ) wich sends no output to the browser. This page sends the browser to another page (eg...
1
by: Danny Anderson | last post by:
Hola, PHP folk! I have a php page that contains a self-processing form. The form holds search results. The search terms originally came from the previous page, but the user can repeatedly...
11
by: Francisco Mendez | last post by:
I get the following message when trying to run my script: "Warning: Cannot modify header information - headers already sent by (output started at /var/www/html/newcustomer.php:23) in...
6
by: bissatch | last post by:
Hi, I am trying to use the following function: header("Location: http://www.mysite.co.uk/home/update/index.php"); ....but getting the following error: Warning: Cannot modify header...
7
by: beliavsky | last post by:
Ideally, one can use someone's C++ code by just looking at the header files (which should contain comments describing the functions in addition to function definitions), without access to the full...
1
by: Roger | last post by:
I couldn't find anything at http://www.mvps.org/access/reports/index.html I have a report with static (name, address, etc) in its report header and a subreport in the report's detail section ...
23
by: lwoods | last post by:
I am trying to pass some info to another page on my site. I set "session_start()" in page 1, assign a session variable to a value, then execute a "header('Location: ....')." But on the target...
21
by: cman | last post by:
does anyone know why i can't generate images with: header("Content-type:image/jpeg"); imagejpeg($img_number); i've tried different examples but i always get a text output as if the header...
10
by: universalbitmapper | last post by:
Hi, I'm trying a simple form.html that call a .html script that begins with: <?php header("This is a test"); ?> When I click on the link, I get blank page.
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.