473,763 Members | 9,161 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

"header()"funct ion related question

18 New Member
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 1575
ak1dnar
1,584 Recognized Expert Top Contributor
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 Recognized Expert Expert
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 Recognized Expert Specialist
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
dhillarun
18 New Member
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 Recognized Expert Top Contributor
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
dhillarun
18 New Member
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
4443
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 second.php) with the header("Location:") function. second.php doesn't either send any output to the browser. The browser is then send to another page also with the header() function. Now my problem: I have to send user and password data...
1
3140
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 refine the results on the page in question until the target item can be found. This search refinement is where the self-processing form comes to play. The search results are listed in a table with a radio button at the end of each row. What I...
11
6078
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 /var/www/html/newcustomer.php on line 332" ....newcustomer.php:23 is where my script begins, at line 23. before that line, only comments.
6
2369
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 information - headers already sent by (output started at
7
25582
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 source code. Can analogs of C++ header files be created for Python code? Python "header" files could list only the 'def' statements and docstrings of Python functions and classes, but that does not tell you what the functions return. One could...
1
3305
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 the subreport has column headings in both its report and page headers (until I figure out which is best) when I print the report, the subreport headings show on the first
23
3651
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 page I don't get any session variable values! BTW, I used a relative location in the Location header, not an absolute URL. The behavior looks like it started another session, but it should not have. Ideas? TIA,
21
21346
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 doesn't make a difference at all. <?php //random_number.php $img_number = imagecreate(100,50);
10
2452
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
9387
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
10148
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
10002
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 tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
9938
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 Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
9823
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 protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
6643
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
5406
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
2
3528
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
2794
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.