Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8844163
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 14, 20262026-06-14T11:25:03+00:00 2026-06-14T11:25:03+00:00

I am having an issue getting an iframe to display MHT files: if( strtolower(

  • 0

I am having an issue getting an iframe to display MHT files:

if( strtolower( substr( $filename , -4 ) ) == ".mht" ){

    $filename = str_replace( "/" , "\\" , $filename );

    header("Content-type: $filetype");
    header("Content-Length: $filesize");
    header('Content-Disposition: attachment; filename="'.$title.'.mht"');

    readfile( HT_STORAGE . $filename );
}
else{
    $filename = str_replace( "\\" , "/" , $filename );
    header( "location: https://secure.***************.com/" . $filename );
}

The above method works, but it requires two steps (download and open) that my clients aren’t happy about.

As you can see, right now I am simply forcing the browser to open the MHT as a download. I want it to redirect using a header location so that it displays the MHT within this iframe like it does for files who don’t have the MHT extension. I am assuming that this is simply a header call that tells the browser that its MHT content. With a regular redirect, the browser just shows a bunch of MHT tags, no actual content (which is why I am assuming that a special header is required). Any ideas?

EDIT:

Here is some more information I found regarding this issue. The MHT file contains several segments that look like this:

From: "Saved by Windows Internet Explorer 9"
Subject: Print Preview
Date: Tue, 2 Aug 2011 12:06:51 -0500
MIME-Version: 1.0
Content-Type: multipart/related;
type="text/html";
boundary="----=_NextPart_000_0186_01CC510C.A9789090"
X-MimeOLE: Produced By Microsoft MimeOLE V6.1.7600.16807

This is a multi-part message in MIME format.

AND

------=_NextPart_000_0186_01CC510C.A9789090
Content-Type: application/octet-stream
Content-Transfer-Encoding: quoted-printable
Content-Location: https://*******.net/packages/js/jquery.header.js

For some reason, if I use the attachment methodology and “open” the file, IE/Firefox has no problem rendering the document. If I use the header “location” method, it just displays the contents of the file (html tags, mime stuff, etc…), the the interpreted content. Doings this displays the raw HTML output, rather than actually displaying the MHT page:

if( strtolower( substr( $filename , -4 ) ) == ".mht" ){

    $filename = str_replace( "\\" , "/" , $filename );

header("Content-type: message/rfc822");
header( "location: " . $filename );
//header("Content-Length: $filesize");
//header('Content-Disposition: attachment; filename="'.$title.'.mht"');

//readfile( HT_STORAGE . $filename );
}
else{
$filename = str_replace( "\\" , "/" , $filename );
header( "location: https://secure.*****************.com/" . $filename );
}

By using content-type and location, the output is as follows on IE and FF (and most likely all other browsers):

From: "Saved by Windows Internet Explorer 9"
Subject: Print Preview
Date: Tue, 2 Aug 2011 12:06:51 -0500
MIME-Version: 1.0
Content-Type: multipart/related;
    type="text/html";
    boundary="----=_NextPart_000_0186_01CC510C.A9789090"
X-MimeOLE: Produced By Microsoft MimeOLE V6.1.7600.16807

This is a multi-part message in MIME format.

------=_NextPart_000_0186_01CC510C.A9789090
Content-Type: text/html;
    charset="utf-8"
Content-Transfer-Encoding: quoted-printable
Content-Location: https://kinnser.net/am/printwrapper.cfm?PatientTaskKey=36184728

=EF=BB=BF<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" =
"http://www.w3c.org/TR/1999/REC-html401-19991224/loose.dtd">
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" =
"http://www.w3.org/TR/html4/loose.dtd"><HTML><HEAD><TITLE>Print=20
Preview</TITLE>...

So rather than actually rendering the MHT, it just spits out all the tags and data.

Any ideas? Should I have to strip the “MIME” data off the files?:

------=_NextPart_000_0186_01CC510C.A9789090
    Content-Type: text/html;
        charset="utf-8"
    Content-Transfer-Encoding: quoted-printable
    Content-Location: https://kinnser.net/am/printwrapper.cfm?PatientTaskKey=36184728

If so, then how?

Edit

Ironically, if I set it up as content-disposition: attachment and use the readFile, I can open the document and it displays properly. Only if I try to directly inject it inline into the iframe does it render source code and no content. Any ideas?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-14T11:25:04+00:00Added an answer on June 14, 2026 at 11:25 am

    There is currently a known issue with Google-Chrome when viewing MHTs – it will always treat them as Content-Disposition: attachment and download them.

    IE should always view MHTs fine.

    Firefox will view them fine, if you install a plugin for it.

    If the browser was actually able to display MHTs correctly, then the following headers should be sufficient:

    Content-Type: message/rfc822
    Content-Disposition: inline
    

    I was running into issues with Chrome viewing MHT files as well, and in the end the solution I used was to convert the MHT to a single HTML page on the fly. This worked for the situation I was dealing with, but may not work for generic MHT files.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm having an issue with getting the fancybox iframe to load in the browser.
I'm having an issue getting files loaded into an app called GCS, by dragging
Having an issue with getting a makefile to find the correct libraries and header
Currently having an issue with getting the CSS to display a mockup page correctly.
I'm having an issue getting a LINQ query to work. I have this XML:
I'm having an issue getting some code to work. Is there a way to
I'm having an issue getting this CSS for a sprite sheet to work on
I'm having an issue getting Appstats to work correctly. Using /appstats or /appstats/stats ends
I'm having an issue getting the correct value from my drop down box. Basically
Im having an issue where Im getting an empty value for the value of

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.