473,394 Members | 1,645 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,394 software developers and data experts.

Problem in downloading a excel file in IE6 & IE7

vivekgs2007
Hi to all,
i am written a code for downloading the excel file with the records from the mysql..all r working fine but the problem is...it is not downloading in IE6 and IE7...i dont no where is the problem is..and not showing any error msg also please help me this the code is
Expand|Select|Wrap|Line Numbers
  1. <?php
  2. $today = date("d-m-Y");
  3. session_cache_limiter('none');
  4. header("Expires: 0");
  5. header("Last-Modified: " . gmdate("D, d M Y H:i:s") . " GMT");
  6. header("Cache-Control: must-revalidate, post-check=0, pre-check=0");
  7. header("Cache-Control: post-check=0, pre-check=0", false);
  8. header("Pragma: no-cache");
  9. header("Content-Type: application/force-download");
  10. header("Content-Type: application/octet-stream");
  11. header("Content-Type: application/download");
  12. header('Content-Description: File Transfer');
  13. header("Content-type: application/vnd.ms-excel;charset:UTF-8");
  14. header("Content-Disposition: inline; attachment; filename=RegisterUser_$today.xls"); 
  15. print "\n";
  16. ?>
  17.  
Sep 8 '10 #1
6 3805
JKing
1,206 Expert 1GB
Not 100% sure about this but other users have reported problems downloading files in IE when setting the Cache-Control and Pragma headers.

Try commenting those lines out and running the file in IE to see if that is the issue. If it is you can use an if block to only set those headers for non-IE browsers.
Sep 8 '10 #2
Thank you very much for your replay..I will try and get back to u..
Sep 9 '10 #3
Atli
5,058 Expert 4TB
Your "Content-Disposition" header is malformed. It should be "inline" OR "attachment", not both. ("attachment" if you want the file downloaded, "inline" if you want it displayed.)
Sep 10 '10 #4
I have removed inline from the line and updated it to
Expand|Select|Wrap|Line Numbers
  1. header("Content-Disposition: attachment; filename=RegisterUser_$today.xls"); 
But still it is not downloading wts the problem
Sep 13 '10 #5
Atli
5,058 Expert 4TB
Ok, here are a few things to consider.
  1. Most important thing when debugging: Turn on the error messages.. If you have them on, let us know so we won't have to bug you about it.
  2. You are setting the Content-Type header four times, and the Cache-Control header twice. They should only be set once per response. (Excluding multi-part block headers.) You should only expect the response to include the latest value you set for any one header. (Meaning, you should consolidate/discard the other values.)
  3. The last Content-Type you use is set as: "Content-type: application/vnd.ms-excel;charset:UTF-8". The format for a header is supposed to be: "Content-Type: <type name>; charset=<charset>". (See the HTTP Header Field Definitions.) You need to fix your version, or browsers may be unable to parse it correctly.
  4. Whats with the print("\n"); command on the last line? If you are sending a file, you shouldn't output anything other than the file data, or you risk corrupting it.
  5. Your session_cache_limiter('none'); call is invalid. The value "none" is not a valid parameter, and just causes the function to do nothing. The only valid values are: nocache, private, private_no_expire, or public. - You should try "nocache".
  6. If you plan on using the session_cache_limiter function, you should not manually set the Cache-Control, Expires, Last-Modified, or Pragma headers. The function will take care of that for you.
Sep 13 '10 #6
Thank you for your replay.I made a many mistake in my coding.from your suggestion i corrected my coding like this
Expand|Select|Wrap|Line Numbers
  1. <?php
  2. error_reporting(E_ALL);
  3. ini_set('display_errors', true);
  4. $today = date("d-m-Y");
  5. header("Expires: 0");
  6. header("Cache-Control: must-revalidate, post-check=0, pre-check=0");
  7. header("Pragma: no-cache");
  8. header('Content-Description: File Transfer');
  9. header("Content-type: application/vnd.ms-excel;");
  10. header("Content-Disposition: attachment; filename=RegisterUser_$today.xls"); 
  11. ?>
  12.  
But still it not coming in IE6 And IE7 its coming perfect in firefox and other browsers
Sep 14 '10 #7

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

Similar topics

2
by: sakons | last post by:
I have created excel file with data from a query #in asp or asp.net+c but when I run the applicaiotn i get the open /save popup when I choose open -> the file is opened in the IE (and is seen as a...
0
by: Jörg Braun | last post by:
Hello NG, i have a problem With WebRequest! i want to download a htaccess saved file over a proxyconnetion with authentication. Download a file what is not saved with htaccess is no problem,...
4
by: moondaddy | last post by:
Using vb.net I need to download image files to the client browser where they can save to disk. Below is some sample code I'm using. when I run this the File Download window in the browser says: ...
0
by: Sathya | last post by:
Hi Am using an ASP.NET website. i have an excel template stored in a folder in the server. the excel template already has some data inside. i need to add some more data to the excel sheet...
4
by: Kevin R. | last post by:
Greetings, I have the following code that attempts to download an excel file: System.Web.HttpContext.Current.Response.ContentType = "application/vnd.ms-excel"; ...
0
by: Andrix | last post by:
HI, I have this code to do an .xls from a data grid, and then download to the client machine. In my intranet works excelente. But in the internet, when i click in the button "Export to Excel"...
4
by: kkadakia | last post by:
I have a VB code that will allow me to browse for a Excel file. After selecting that file, I want it to imported into Access. Following is the code for browsing a Excel file: Private Sub...
2
by: dyc | last post by:
Can anyone give a simple example, showing how to read data from excel or in other word which means that extract the necessary data from Excel file.... Can someone show me the step?Firstly what...
0
by: jh8026 | last post by:
My problem seems to be regarding permissions, but I'm not sure why. I am developing an asp.net web application that needs to pull and display information from an excel file located on a server...
0
by: student491 | last post by:
hello, I opened the excel file by using workbook.open() method... Now i want to read the data from the excel file.. & save it into array. help out .. how to do this. Then i want to pass...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
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: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
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
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
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...
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.