abdfahim Posted June 9, 2008 Share Posted June 9, 2008 I have an excel file with multiple worksheet in server. When I try to download that file using header function, it download an excel file with garbage text on a sheet. The code I used is $savepath="C://program files/apache/htdocs/myexcelfile.xls"; header("Pragma: public"); header("Expires: 0"); header("Cache-Control: must-revalidate, post-check=0, pre-check=0"); header("Content-Type: application/vnd.msexcel"); header( "Content-Disposition: attachment; filename=".basename($savepath)); header( "Content-Description: File Transfer"); header('Accept-Ranges: bytes'); header('Content-Length: ' . filesize($savepath)); readfile($savepath); What wrong did I write? Link to comment https://forums.phpfreaks.com/topic/109428-problem-with-downloading-excel-file-from-server-header-problem/ Share on other sites More sharing options...
jonsjava Posted June 9, 2008 Share Posted June 9, 2008 here's a list of all mime headers for excel files, hopefully one will work for you: application/msexcel application/x-msexcel application/x-ms-excel application/vnd.ms-excel application/x-excel application/x-dos_ms_excel application/xls application/x-xls zz-application/zz-winassoc-xls Oh, and I didn't see anything wrong with your usage of the mime, so that's why I posted the list. If one fails..... Link to comment https://forums.phpfreaks.com/topic/109428-problem-with-downloading-excel-file-from-server-header-problem/#findComment-561371 Share on other sites More sharing options...
abdfahim Posted June 10, 2008 Author Share Posted June 10, 2008 I use all of ur listed mimes with no success . Every time it download the file but inside the file all are garbages. Also my original doc in the server has 8 sheets whereas the downloaded one has only one sheet with all garbages !! Link to comment https://forums.phpfreaks.com/topic/109428-problem-with-downloading-excel-file-from-server-header-problem/#findComment-561764 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.