Jump to content

[SOLVED] getimagesize() stopped working?


acctman

Recommended Posts

i noticed today that all my sites that use the fuction getimagesize() have stop working... I ran a test script and received the error below.

 

Warning: getimagesize(http://www.site.com/files/tfile.jpg) [function.getimagesize]: failed to open stream: Cannot assign requested address in /home/site/public_html/files/test4.php on line 2

width:

height:

 

$size = getimagesize("http://www.ratemybottom.com/files/tfile.jpg");

echo "width: $size[0]<br>";
echo "height: $size[1]<br>";
echo "$size[3]";  

Link to comment
Share on other sites

oh, haha, i was unaware. well i might suggest in that case simply making your own getimagesize() function, which should be simple enough

 

 

 

also, the link is dead, the image does not load, perhaps that is the problem?

 

after all it says "failed to open stream: "

Link to comment
Share on other sites

oh, haha, i was unaware. well i might suggest in that case simply making your own getimagesize() function, which should be simple enough

 

 

 

also, the link is dead, the image does not load, perhaps that is the problem?

 

after all it says  "failed to open stream: "

 

uhhh, i'm not being rude but please stop responding. :(

Link to comment
Share on other sites

give us the function. . . .

 

What?  It's in the GD library.  Any change in PHP version or ini settings on your site?

 

no recent changes, last change to php.ini was on May 23rd. everything was working fine yesterday

Link to comment
Share on other sites

Can we see the code of test4.php please?

 

this is all that is inside the test4.php file... i'm trying to figure out why it would just stop working

<?php
$size = getimagesize("http://www.site.com/files/tfile.jpg");

echo "width: $size[0]<br>";
echo "height: $size[1]<br>";
echo "$size[3]";  
?>

Link to comment
Share on other sites

 

I used "site.com" out side of the coded tag so my url wouldn't be picked up in SE searchs, most users on the site do the same thing. The actual url and link in the script on my server is 100% correct. I also have 5 our sites in which the coding hasn't been touched, and the getimagesize has stopped working.

 

the problem is not the coding, it seems like something was auto updated or a bug in GD or something

Link to comment
Share on other sites

Depending on what version of php you're using you might want to try the following, Otherwise uncomment the second line and see if you are getting an array assigned to the size var.

<?php
$size = getimagesize("http://www.site.com/files/tfile.jpg");
//var_dump($size);
echo "width: {$size[0]}<br>";
echo "height: {$size[1]}<br>";
echo "{$size[3]}";
?>

Link to comment
Share on other sites

Is the file you're trying to access a local file (i.e. on the same server as your script) or a remote file?

 

Ken

 

yes the test file in local in the same folder as the test file. test4.php and tfile.jpg are in the same folder

Link to comment
Share on other sites

Depending on what version of php you're using you might want to try the following, Otherwise uncomment the second line and see if you are getting an array assigned to the size var.

<?php
$size = getimagesize("http://www.site.com/files/tfile.jpg");
//var_dump($size);
echo "width: {$size[0]}<br>";
echo "height: {$size[1]}<br>";
echo "{$size[3]}";
?>

 

i just tried that, var dump uncommented produces the same error but with bool(false)

Link to comment
Share on other sites

Is the file you're trying to access a local file (i.e. on the same server as your script) or a remote file?

 

Ken

 

yes the test file in local in the same folder as the test file. test4.php and tfile.jpg are in the same folder

 

If you're doing it locally why don't you do it without the url?

 

<?php
$size = getimagesize("tfile.jpg");
var_dump($size);
echo "width: {$size[0]}<br>";
echo "height: {$size[1]}<br>";
echo "{$size[3]}";
?>

 

EDIT

 

And if that doesn't work test it qith a different image to make sure the image itself isn't corrupt

Link to comment
Share on other sites

Is the file you're trying to access a local file (i.e. on the same server as your script) or a remote file?

 

Ken

 

yes the test file in local in the same folder as the test file. test4.php and tfile.jpg are in the same folder

 

If you're doing it locally why don't you do it without the url?

 

<?php
$size = getimagesize("tfile.jpg");
var_dump($size);
echo "width: {$size[0]}<br>";
echo "height: {$size[1]}<br>";
echo "{$size[3]}";
?>

 

EDIT

 

And if that doesn't work test it qith a different image to make sure the image itself isn't corrupt

 

i did some more testing and it works without putting the in http://... just the test file was in the same directory. so what works now is inputing the abosolute server path to the image folders and locations. very odd considering the original examples I got for getimagesize came from php.net which gives the usage of http:// url as an example http://us2.php.net/getimagesize

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.