Jump to content

Content Type Issue


shaunie

Recommended Posts

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?

Link to comment
Share on other sites

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.

Link to comment
Share on other sites

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>

Link to comment
Share on other sites

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>

Link to comment
Share on other sites

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

Link to comment
Share on other sites

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.

Link to comment
Share on other sites

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?

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.