1

I'm trying to parse out some images from blog posts to create little thumbnails. One particular image is failing on the web server but not on my laptop.

Here's some test code:

$vars = getimagesize( 'http://thebestcamera.com/blog/wp-content/uploads/2010/02/img_0084-150x150.png' );

var_dump( $vars );

The error log does:

PHP Warning:  getimagesize(http://thebestcamera.com/blog/wp-content/uploads/2010/02/img_0084-150x150.png) [<a href='function.getimagesize'>function.getimagesize</a>]: failed to open stream: HTTP request failed! HTTP/1.1 404 Not Found

If I use curl I get a 404 from the server but I get the image if I do it from the laptop:

 curl http://thebestcamera.com/blog/wp-content/uploads/2010/02/img_0084-150x150.png
<!DOCTYPE HTML PUBLIC "-//IETF//DTD HTML 2.0//EN">
<html><head>
<title>404 Not Found</title>
</head><body>
<h1>Not Found</h1>
<p>The requested URL /blog/wp-content/uploads/2010/02/img_0084-150x150.png was not found on this server.</p>
<hr>
<address>Apache/2.2.3 (CentOS) Server at thebestcamera.com Port 80</address>

Any thoughts?

Mark Steudel
  • 1,662
  • 3
  • 18
  • 31
  • 1
    This sounds like an anti-scraping measure (e.g. detecting whether the "user-agent" header is a mainstream browser) – Pekka Jan 09 '11 at 22:04
  • Ok it must be a server redirect issue. If I put www.thebestcamera.com it works ... wonder what's causing that. – Mark Steudel Jan 09 '11 at 22:05
  • @Pekka: was just about to write something very similar. – thirtydot Jan 09 '11 at 22:05
  • @Mark then it might be a header redirect that the http wrapper doesn't follow (normal browsers do) – Pekka Jan 09 '11 at 22:06
  • I bet it must be how the server resolves the domain name, because from my laptop it works using all the same testing. – Mark Steudel Jan 09 '11 at 22:17
  • @Mark what does a `ping thebestcamera.com` resolve to on each system? – Pekka Jan 09 '11 at 22:18
  • @pekka - great quesiton, I ran ping from the server and it returned 127.0.0.1, if I ping www.thebestcamera.com on the server, it returns it's actual ip address. If I ping thebestcamera.com on my laptop it returns the actual ip address. Should servers normally resolve the domain to 127.0.0.1 or should it resolv to it's actual public ip? – Mark Steudel Jan 10 '11 at 19:24
  • @Mark in that case, the call probably fails because your server has different rules for incoming calls on that address. – Pekka Jan 10 '11 at 19:52
  • @Mark - did you find the solution for this error? – Laurence Tuck Nov 28 '12 at 11:34

0 Answers0