1

I'm using the getimagesize() function in PHP and it keeps returning an error:

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

I'm not doing anything strange with it. The only problem I can imagine is that the path URL is another PHP script that returns a page with an image header, and there is an ampersand in that URL.

Here is my code:

$location = "image.php?name=username&pic=picture";
$size = getimagesize($location);
2
  • oh come on, someone has to know this Commented Mar 12, 2010 at 4:24
  • 5
    you asked it 8 minutes ago. chill. Commented Mar 12, 2010 at 4:25

1 Answer 1

2

You are expecting the php script to get executed? In that case you shouldn't try to open the file directly (it wont be executed) you should do something like

$location = "http://server.com/image.php?name=username&pic=picture";
$size = getimagesize($location);
Sign up to request clarification or add additional context in comments.

10 Comments

Am I crazy? I just saw two other answers come and disappear while I was typing...
But then I get errors about direct URL something or other not being enabled on the server. I ran into that once with a different function and I know how to fix it, but I'd rather not as it makes things less secure. But the thing is, why shouldn't it execute from the relative directory path?
I deleted my answer because I really wasn't sure about it.
@RobHardgood: Because it's not treating it like a URL with a query string, it's treating it as a local file with the name image.php?name=username&pic=picture.
I see... Is there any way around this besides using the full path, which is less secure and won't necessarily always be static?...
|

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.