shaunie Posted March 5, 2012 Share Posted March 5, 2012 Hi, I am trying to get google docs viewer integrated into my website. It is working for ppt files but not pptx files. I have read up and I understand I need to alter the header to: header('Content-Type: application/vnd.openxmlformats-officedocument.wordprocessingml.document'); However when I do this I click on the link and it just downloads index.php. Any idea what I am doing wrong here? Quote Link to comment https://forums.phpfreaks.com/topic/258346-content-type-issue/ Share on other sites More sharing options...
requinix Posted March 5, 2012 Share Posted March 5, 2012 That header tells whatever is downloading the file what type of file it is (and thus what should be done with it). If you're going there with your browser and it doesn't know how to handle that content-type then it'll do its default action: download it. From the ten seconds of searching I just did, what you need is to embed the viewer in a page and point the viewer to wherever the pptx comes from. Google's thing then downloads the file and displays it. Quote Link to comment https://forums.phpfreaks.com/topic/258346-content-type-issue/#findComment-1324291 Share on other sites More sharing options...
shaunie Posted March 5, 2012 Author Share Posted March 5, 2012 Hi, Thank you for your reply, I have set the page up to do this, however it only works for ppt files, not pptx. Here is my code: <div id="page"> <? $rows = db_fetch_object($rs); ?> <iframe src="http://docs.google.com/viewer?url=www.domain.com%2F<?= urlencode($rows->filename); ?>&embedded=true" width="750" height="500" style="border: none;"></iframe> </div> Quote Link to comment https://forums.phpfreaks.com/topic/258346-content-type-issue/#findComment-1324293 Share on other sites More sharing options...
requinix Posted March 5, 2012 Share Posted March 5, 2012 Well that code isn't to blame for it. If you can share, what's the URL you're using for one of these "bad" PPT files? (An example file is fine too.) Quote Link to comment https://forums.phpfreaks.com/topic/258346-content-type-issue/#findComment-1324310 Share on other sites More sharing options...
shaunie Posted March 6, 2012 Author Share Posted March 6, 2012 Hi, Here are 2 links that should demonstrate the problem, the first link displays a ppt file, and the 2nd link attempts to display a pptx file: http://bhvs.org.uk/index2.php?action=ppt http://bhvs.org.uk/index2.php?action=pptx As you can see, the 2nd link just displays 'PK' instead of the actual powerpoint file contents. Here is the link to the article that led me to believe it is the content type that is the problem: http://groups.google.com/a/googleproductforums.com/forum/#!category-topic/docs/documents/7j_BXBtQWQg Here is my code: index2.php: <? include ('application.php'); include ('templates/header.php'); switch ($_GET['action']) { case "ppt" : display_ppt(); break; case "pptx" : display_pptx(); break; } include ('templates/footer.php'); // Functions function display_ppt(){ global $CFG; include('templates/ppt.php'); } function display_pptx(){ global $CFG; include('templates/pptx.php'); } ?> ppt.php: <div id="content"> <div id="sidebar"> </div> <div id="page"> <iframe src="http://docs.google.com/viewer?url=www.bhvs.org.uk%2Fuploads%2Ftest.ppt&embedded=true" width="750" height="500" style="border: none;"></iframe> </div> pptx.php: <div id="content"> <div id="sidebar"> </div> <div id="page"> <iframe src="http://docs.google.com/viewer?url=www.bhvs.org.uk%2Fuploads%2Ftest.pptx&embedded=true" width="750" height="500" style="border: none;"></iframe> </div> Quote Link to comment https://forums.phpfreaks.com/topic/258346-content-type-issue/#findComment-1324441 Share on other sites More sharing options...
requinix Posted March 6, 2012 Share Posted March 6, 2012 The problem is with /uploads/test.pptx. Your server is sending the response as a application/zip, which is technically correct (because PPTX files are really just special ZIP files - try renaming one as .zip), but it should be sending the PPTX type. To change that, in a .htaccess somewhere (such as uploads/) add AddType application/whatever-its-supposed-to-be .pptx Quote Link to comment https://forums.phpfreaks.com/topic/258346-content-type-issue/#findComment-1324597 Share on other sites More sharing options...
shaunie Posted March 7, 2012 Author Share Posted March 7, 2012 Hi, Thanks for your reply, I have created an .htaccess file with the following contents: AddType application/vnd.openxmlformats-officedocument.wordprocessingml.document .pptx PPT files are still working, however pptx files return the following message: Sorry, we are unable to generate a view of the document at this time. Please try again later. You can also try to download the original document by clicking here. Quote Link to comment https://forums.phpfreaks.com/topic/258346-content-type-issue/#findComment-1324784 Share on other sites More sharing options...
requinix Posted March 7, 2012 Share Posted March 7, 2012 That MIME type is for DOCX files. Find a different one. Quote Link to comment https://forums.phpfreaks.com/topic/258346-content-type-issue/#findComment-1324786 Share on other sites More sharing options...
shaunie Posted March 7, 2012 Author Share Posted March 7, 2012 Hi, Thanks for your reply, I have modified the MIME type to the following: AddType: application/vnd.openxmlformats-officedocument.presentationml.presentation .pptx Some of the files are working now, but a few still aren't. Unfortunately I can't send the links to these files, do you have any other suggestions of what I could try? Quote Link to comment https://forums.phpfreaks.com/topic/258346-content-type-issue/#findComment-1324791 Share on other sites More sharing options...
requinix Posted March 7, 2012 Share Posted March 7, 2012 Not without knowing what the problem is. Can you at least describe it? Quote Link to comment https://forums.phpfreaks.com/topic/258346-content-type-issue/#findComment-1324795 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.