On Tue, July 31, 2007 12:32 pm, blackwater dev wrote: > I have an excel file that I am generating. If I copy over the > generated > file and then open it in excel, it works fine, if I try to let the > user > download it using the headers below, when I then open it excel > complains > that it is an unrecognizable format and the info is garbled...any > ideas??? > > Thanks! > > header('Pragma: public'); > header("Expires: Mon, 26 Jul 1997 05:00:00 GMT"); > // > Date in the past > header('Last-Modified: '.gmdate('D, d M Y H:i:s') . ' GMT'); > header('Cache-Control: no-store, no-cache, must-revalidate'); > // > HTTP/1.1 > header('Cache-Control: pre-check=0, post-check=0, max-age=0'); > // > HTTP/1.1 > header ("Pragma: no-cache"); > header("Expires: 0"); > header('Content-Transfer-Encoding: none'); > header('Content-Type: application/vnd.ms-excel;'); > // > This should work for IE & Opera > header("Content-type: application/x-msexcel"); > // > This should work for the rest > header('Content-Disposition: attachment; filename="myfile.xls"'); > readfile("/tmp/myfile.xls"); Copy it over how?... Plus, I gotta tell ya, all those goofy extra headers are simply NOT doing what you think they are... First of all, unless you add a ", TRUE" as a second arg, each header() call with the same "XXX: " start is REPLACING the previous ones. So you are ALWAYS using Content-type: application/x-msexcel and you might as well rip the rest of them out. Some headers can have multiple instances (Cache-control) but you only get ONE Content-type. Period. You should also compare the actual bytes of the file you get from the download with the file you copied over. Did PHP add something or strip something out? Usually this problem has a self-evident solution once you identify the problem, so I'll say no more in this vein. And, finally, if you want to support legacy browsers and all kinds of "gotchas" with downloads, read this rant: http://richardlynch.blogspot.com/2006/06/php-downloads-content-disposition.html ymmv -- Some people have a "gift" link here. Know what I want? I want you to buy a CD from some indie artist. http://cdbaby.com/browse/from/lynch Yeah, I get a buck. So? -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php