PHP getimagesize - Could not open stream. Bad request

I get the following error:

getimagesize ( https://static1.squarespace.com/static/570d03d02b8dde8b2642afca/570f74e87c65e4819dec6812/57272dbfb6aa606f78a5d8b5/1470397291105/4XTRYCK3.jpg ): HTTP request failed! failed: failed Invalid HTTP / 1.1 400 request

The image opens without problems in my browser.

Does anyone understand why this fails?

+7
php gd
source share
1 answer

Squarespace rejects any connection where the User-Agent header is not a web browser. This includes CURL and getimagesize.

You can set the user agent header by inserting it into your code:

ini_set('user_agent','Mozilla/4.0 (compatible; MSIE 7.0b; Windows NT 6.0)'); 
+4
source share

All Articles