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 8847071
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 14, 20262026-06-14T12:07:42+00:00 2026-06-14T12:07:42+00:00

I’m attempting to retrieve images from a web page, and it has been working

  • 0

I’m attempting to retrieve images from a web page, and it has been working well so far, except one of the sites I am looking at is serving images as Content-Type: text/html, causing my script to reject it as not a real image.

This is the code snippet I am using to determine content-type:

$accepted_mime = array('image/gif', 'image/jpeg', 'image/jpg', 'image/png');    
$headers = get_headers($image);

// Find the Content-Type header
$num_headers = sizeOf($headers);
for($x=0;$x<$num_headers;$x++) {
    preg_match('/^Content-Type: (.+)$/', $headers[$x], $mime_type);
    if (isset($mime_type[1]) && in_array($mime_type[1], $accepted_mime)) {
        return true;
    }
}

For sites I’ve tried, they return properly (results such as image/gif, image/png, etc), but mpaa.org seems to serve their images with type text/html. Is this normal?

I added a print_r to see the header array returned by get_headers`:

Array
(
    [0] => http://www.mpaa.org/templates/images/header_mpaa_logo.gif
    [1] => Array
        (
            [0] => HTTP/1.1 200 OK
            [1] => Server: nginx/1.2.0
            [2] => Date: Sat, 17 Nov 2012 17:19:06 GMT
            [3] => Content-Type: text/html
            [4] => Connection: close
            [5] => P3P: CP="NON DSP COR ADMa OUR IND UNI COM NAV INT"
            [6] => Cache-Control: no-cache, no-store, must-revalidate
            [7] => Pragma: no-cache
        )

)

I could easily add text/html to my list of accepted content-types, but that’s definitely not the ideal solution 😉 Does anyone know why mpaa.org serves their images with this Content-Type? Is it regular practice to do so (perhaps with legacy websites/servers)?

Thanks 🙂

  • 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-14T12:07:43+00:00Added an answer on June 14, 2026 at 12:07 pm

    The wonderful MPAA is using user-agent sniffing or checking cookies to determine if your browser supports JavaScript. Since you are not specifying a user-agent string or sending cookies, they assume you don’t have JavaScript and return a page saying that, instead of the original image.

    If you load this with a browser, you’ll note that you do get image/gif, and the image you are after: http://www.mpaa.org/templates/images/header_mpaa_logo.gif

    If you make that same request with cURL or Fiddler, or some other oddball user-agent string:

    This site requires JavaScript and Cookies to be enabled. Please change your browser settings or upgrade your browser.

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

Sidebar

Related Questions

That's pretty much it. I'm using Nokogiri to scrape a web page what has
I'm parsing an RSS feed that has an &#8217; in it. SimpleXML turns this
I would like my Web page http://www.gmarks.org/math_in_e-mail.txt on my Apache 2.2.14 server to display
I'm making a simple page using Google Maps API 3. My first. One marker
I have a string like this: La Torre Eiffel paragonata all&#8217;Everest What PHP function
link Im having trouble converting the html entites into html characters, (&# 8217;) i
I want to count how many characters a certain string has in PHP, but
For some reason, after submitting a string like this Jack’s Spindle from a text
I am reading a book about Javascript and jQuery and using one of the
I've got a string that has curly quotes in it. I'd like to replace

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.