bengaltgrs Posted July 4, 2007 Share Posted July 4, 2007 I found the following source code for creating and downloading a file online: <?php $line1="ID\tProduct\tColor\tSales\t"; $line2="1\tPrinter\tGrey\t13\t"; $line3="2\tCD\tBlue\t15\t"; $line4="3\tDVD\tRed\t7\t"; $line5="4\tMonitor\tGreen\t4\t"; $line6="5\tTelephone\tBlack\t2\t"; $data="$line1\n$line2\n$line3\n$line4\n$line5\n$line6\n"; header("Content-type: application/x-msdownload"); header("Content-Disposition: attachment; filename=" . "extraction.xls"); header("Pragma: no-cache"); header("Expires: 0"); print "$header\n$data"; ?> This code works fine on a regular server, but when I tried to put it on my secure server I just got errors. Is there a way to make this work on a secure server? -Chris Quote Link to comment https://forums.phpfreaks.com/topic/58342-file-downloads-on-secure-server/ Share on other sites More sharing options...
john010117 Posted July 4, 2007 Share Posted July 4, 2007 What exactly were the errors that you got? Quote Link to comment https://forums.phpfreaks.com/topic/58342-file-downloads-on-secure-server/#findComment-289311 Share on other sites More sharing options...
bengaltgrs Posted July 4, 2007 Author Share Posted July 4, 2007 The file download dialog still comes up, but the filename is now 'ExportExcel_php' instead of 'extraction.xls', which is the name of the php page which is supposed to do the downloading. Upon pressing the 'Save' button, I get an error saying "Internet Explorer cannot download ExportExcel.php. Internet Explorer was not able to open this Internet site. The requested site is either unavaliable or cannot be found. Please try again later." Quote Link to comment https://forums.phpfreaks.com/topic/58342-file-downloads-on-secure-server/#findComment-289322 Share on other sites More sharing options...
Daniel0 Posted July 4, 2007 Share Posted July 4, 2007 This doesn't fix your proble, but instead of $line1="ID\tProduct\tColor\tSales\t"; $line2="1\tPrinter\tGrey\t13\t"; $line3="2\tCD\tBlue\t15\t"; $line4="3\tDVD\tRed\t7\t"; $line5="4\tMonitor\tGreen\t4\t"; $line6="5\tTelephone\tBlack\t2\t"; $data="$line1\n$line2\n$line3\n$line4\n$line5\n$line6\n"; why not just do this: $data = <<<EOF ID Product Color Sales 1 Printer Grey 13 2 CD Blue 15 3 DVD Red 7 4 Monitor Green 4 5 Telephone Black 2 EOF; Quote Link to comment https://forums.phpfreaks.com/topic/58342-file-downloads-on-secure-server/#findComment-289427 Share on other sites More sharing options...
bengaltgrs Posted July 4, 2007 Author Share Posted July 4, 2007 Is there no solution to this aside from putting the page on an unsecure server? Quote Link to comment https://forums.phpfreaks.com/topic/58342-file-downloads-on-secure-server/#findComment-289828 Share on other sites More sharing options...
Daniel0 Posted July 4, 2007 Share Posted July 4, 2007 I searched Google. Another person had a similar problem. It seemed to work if he didn't send the Pragma: no-cache header. Try to comment that line out and see if it helps. A person at the PHP documentation says that IE (also IE7) is having problems with SSL downloads where the above-mentioned header is sent. Since you are using IE, have you tried another browser (Firefox, Opera, Safari, etc.)? http://php.net/header#74876 The bug in IE I mentioned before is explained here: http://support.microsoft.com/kb/812935 Quote Link to comment https://forums.phpfreaks.com/topic/58342-file-downloads-on-secure-server/#findComment-289862 Share on other sites More sharing options...
bengaltgrs Posted July 4, 2007 Author Share Posted July 4, 2007 Commenting out the 'header("Pragma: no-cache");' line seems to have fixed the problem. I still haven't tested it in any other browser though. Thank you very much for the help. Quote Link to comment https://forums.phpfreaks.com/topic/58342-file-downloads-on-secure-server/#findComment-289923 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.