views:

38

answers:

1

I'm using the getimagesize function in PHP, and the path string contains an ampersand, which otherwise is fine. The page gives me errors where getimagesize() is called. Looking at the source code, though, I see the ampersand is being passed through as & rather than just & I presume this is causing errors because PHP doesn't need to convert it to the html tag in order to find the path, right?

Here is the error:

Warning: getimagesize(image.php?name=username&pic=picture) [function.getimagesize]: failed to open stream: No such file or directory

A: 

If you want getimagesize to fetch the image from a remote server, by sending an HTTP request and downloading it, you need to use an absolute URL (starting with http://domainname.ext/...)


For example, this portion of code :

$url = 'http://static.php.net/www.php.net/images/php.gif?test=glop&blah=huhu';
$data = getimagesize($url);
var_dump($data);

Gives me :

array
  0 => int 120
  1 => int 67
  2 => int 1
  3 => string 'width="120" height="67"' (length=23)
  'bits' => int 7
  'channels' => int 3
  'mime' => string 'image/gif' (length=9)


If you don't want to fetch a remote image, then, you need to specify the path to an image that exists on the same machine than the one where PHP runs.

And, in your case, I doubt that you have a physical file called 'image.php?name=username&pic=picture'.

Pascal MARTIN