473,581 Members | 3,046 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Generating CSV files which open correctly in IE

I'm working on a site which dynamically generates tables of rates in CSV
format. The script which does the work is called generate_stats. php. Here's
the header

header ("Content-type: application/octet-stream");
header ("Content-Disposition: attachment; filename=query-results.csv");
header ("Pragma: no-cache");
header ("Expires: 0");

Now in Mozilla, the user is correctly asked if they want to save or open a
file called query-results.csv

However in IE5 the user is asked if they want to open or save a file called
generate_stats. php.
If they open they're then asked if they want to open or save a file called
query-results.csv.

Does anyone know how I can arrange for IE to immediately open a file called
query-results.csv?

Thanks
--
Bryan

Jul 17 '05 #1
2 2742
Bryan Feeney wrote:
I'm working on a site which dynamically generates tables of rates in CSV
format. The script which does the work is called generate_stats. php. Here's
the header

header ("Content-type: application/octet-stream");
header ("Content-Disposition: attachment; filename=query-results.csv");
header ("Pragma: no-cache");
header ("Expires: 0");

Now in Mozilla, the user is correctly asked if they want to save or open a
file called query-results.csv

However in IE5 the user is asked if they want to open or save a file called
generate_stats. php.
If they open they're then asked if they want to open or save a file called
query-results.csv.

Does anyone know how I can arrange for IE to immediately open a file called
query-results.csv?


IE is braindead (as if you didn't already know that) and defaults to the
script name on saving files totally ignoring the disposition filename.

Link to your script with:
http://www.server.com/generate_stats...ry-results.csv
.... and it might just be able to fathom out what you want it to do. The
server strips off the last part and shoves it in $_SERVER['PATH_INFO']
Jul 17 '05 #2
"Bryan Feeney" <bf*****@oceanf ree.net> wrote in message news:<2i******* *****@uni-berlin.de>...
I'm working on a site which dynamically generates tables of rates in CSV
format. The script which does the work is called generate_stats. php. Here's
the header

header ("Content-type: application/octet-stream");
header ("Content-Disposition: attachment; filename=query-results.csv");
header ("Pragma: no-cache");
header ("Expires: 0");

Now in Mozilla, the user is correctly asked if they want to save or open a
file called query-results.csv

However in IE5 the user is asked if they want to open or save a file called
generate_stats. php.
If they open they're then asked if they want to open or save a file called
query-results.csv.

Does anyone know how I can arrange for IE to immediately open a file called
query-results.csv?


<?php
$file_name = 'file.csv';
header('Content-Type: text/x-csv');
// IE need specific header (to show the correct name of downloading file)
// grabbed from phpMyAdmin...
if (strstr($_SERVE R['HTTP_USER_AGEN T'], 'MSIE')) {
header('Content-Disposition: inline; filename="' . $file_name . '"');
header('Cache-Control: must-revalidate, post-check=0, pre-check=0');
header('Pragma: public');
} else {
header('Content-Disposition: attachment; filename="' . $file_name . '"');
header('Pragma: no-cache');
}
//rest...
?>

--
| Just another PHP saint |
Email: rrjanbiah-at-Y!com
Jul 17 '05 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

0
1897
by: Dan Gass | last post by:
The difflib.py module and the diff.py tools script in Python 2.4 alpha 3 now support generating side by side (with intra line differences) in HTML format. I have found this useful for performing build release comparisons (I use a script to generate a main page showing all the files that were changed in a build with hyperlinks to side by side...
6
1800
by: vasilijepetkovic | last post by:
Hello All, I have a problem with the program that should generate x number of txt files (x is the number of records in the file datafile.txt). Once I execute the program (see below) only one file (instead of x files) is created. The file created is based on the last record in datafile.txt. The program is as follows:
2
1632
by: google.groups.tr | last post by:
I have an Access 97 database that has a routine to generate a unique report as a PDF file and email it to one person, and loops about 300 times. Each instance through the loop uses a registry entry to pre-populate the desired filename for the PDF file it generates. The PDFs are generated, attached and emailed in the loop as they're...
6
2294
by: Alan Krueger | last post by:
Is there a way to automatically include C# files (.cs) generated by a third-party tool into a Visual C# .NET build? It's possible the set of files generated by this tool might change. Adding these files manually to the project would work in the short term, but this would require manual intervention if these generated files happened to...
3
1886
by: daniele.balducci | last post by:
Hi All, I'm generating XLS files from ASP(.Net) code using the usual code chunks ... Response.ContentType = "application/vnd.ms-excel" Response.AppendHeader("Content-Disposition", "attachment; filename=""" & NomeFile & """") Response.Flush() Response.write("<table border=""1"" .....
1
3222
by: Xah Lee | last post by:
The following is a program to generate thumbnail images for a website. Useful, if you want to do that. It is used to generate the thumbnails for my “Banners, Damsels, and Mores” project gallery. ( http://xahlee.org/Periodic_dosage_dir/lanci/lanci.html ) Comments and versions in other lang welcome. Xah
1
2193
by: Nathan Sokalski | last post by:
Visual Studio 2005 recently stopped generating the *.designer.vb files for my *.aspx and *.ascx files. I am using Service Pack 1, and do not believe I did anything differently than normal prior to this happening. Is there anything that could have caused this? Does anyone know of a way to fix it? Thanks. -- Nathan Sokalski...
10
3162
by: lancer6238 | last post by:
Hi all, I'm having programs reading from files. I have a text file "files.txt" that contains the names of the files to be opened, i.e. the contents of files.txt are Homo_sapiens.fa Rattus_norvegicus.fa (They are FA files that can be opened in any text editor.)
2
1457
by: Draggonn | last post by:
Hello all. I'm not sure if this is the right part of the forum to ask, but I couldn't find any better place. I am trying to make a program that will take a file of any extension, and split it into several files, and then recompose these files into the original file. But for some reason, even though the copy file size appears correctly when the...
0
7886
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, people are often confused as to whether an ONU can Work As a Router. In this blog post, well explore What is ONU, What Is Router, ONU & Routers main...
0
8159
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. ...
0
8312
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...
1
7920
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...
1
5685
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupr who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes...
0
5366
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...
0
3835
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
2312
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
1
1413
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

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.