Current location: Hot Scripts Forums » Programming Languages » PHP » Problem in donwloading document using header


Problem in donwloading document using header

Reply
  #1 (permalink)  
Old 11-18-05, 10:50 PM
tejash tejash is offline
New Member
 
Join Date: Jul 2005
Posts: 1
Thanks: 0
Thanked 0 Times in 0 Posts
Problem in donwloading document using header

Hi Friends,
This is tejash patel.
I am getting problem in downloading documents using "header".
On click of download button the page is called itself.
I wrote the following code.

$fp = fopen($name, "rb");
header("Content-type: application/x-download");
header("Content-Disposition: attachment; filename=filename");
header("Content-Transfer-Encoding: binary");
header("Content-Length: $download_size");
fpassthru($fp);
fclose($fp);
exit;

This code is work fine in firefox mozila.
But in IE it creates problem. When is ask for download if i click on "Open" instead of "Save" then it will again as for "Save" or "Open". Now click on open, it will opent the document.

If anyone of your guys have solution of this problem then please reply me as soon as possible.

Thank you.

- Tejash Patel
Reply With Quote
  #2 (permalink)  
Old 11-19-05, 01:37 AM
NeverMind's Avatar
NeverMind NeverMind is offline
Community VIP
 
Join Date: Aug 2003
Location: K.S.A
Posts: 2,257
Thanks: 0
Thanked 2 Times in 1 Post
I am having the same problem with a similar script.. I don't think it's a big deal so I just ignored it!

maybe someone else knows a solution for this.
__________________
PHPSimplicity
We don't need a reason to help people - Zidane [FF9]
Reply With Quote
  #3 (permalink)  
Old 11-19-05, 02:11 AM
Nico's Avatar
Nico Nico is offline
Community Leader
 
Join Date: Sep 2005
Location: Spain
Posts: 8,075
Thanks: 11
Thanked 88 Times in 83 Posts
Try adding this code to your script. This should avoid IE errors!
Yes, both are left in blank, but to me it seems like this is how it works!

PHP Code:

 header("Cache-Control: ");

 
header("Pragma: "); 
Reply With Quote
  #4 (permalink)  
Old 11-19-05, 02:48 AM
Nico's Avatar
Nico Nico is offline
Community Leader
 
Join Date: Sep 2005
Location: Spain
Posts: 8,075
Thanks: 11
Thanked 88 Times in 83 Posts
This could may fix the error as well. Add this before sending the headers!

PHP Code:

if (strstr($_SERVER['HTTP_USER_AGENT'], "MSIE")){

    
$file preg_replace('/\./''%2e'$filesubstr_count($file'.') - 1);

Reply With Quote
Reply

Bookmarks


Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On

Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
The Art Nexus seeking PHP programmers TheArtNexus Job Offers & Assistance 5 02-26-08 03:08 AM
Download problem lcwei81 PHP 4 09-26-05 01:28 AM
header problem phplearner PHP 7 08-02-05 03:19 AM
header redirect problem loeddie PHP 2 05-18-05 11:22 AM
I most definately suggest DevelopingCentral.com For Any Website Design/Development! Salty777 General Advertisements 2 10-01-04 04:27 AM


All times are GMT -5. The time now is 06:19 AM.
vBulletin® Copyright ©2000 - 2012, Jelsoft Enterprises Ltd.