Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

imagecreatefromjpeg fails to load URL

Status
Not open for further replies.

whirlpool6

Technical User
Sep 2, 2007
58
0
0
JP
hello everyone.

my php server is a linux environment. i have gd2_lib installed in linux server. when i tried to access image URL's with imagecreatefromjpeg, nothing happens. imagecreatefromjpeg fails, it returns a false.

may i know what are the possible causes for this? i really don't know. pls help ... thanks a lot.
 
post the code you are using.

also determine whether allowurl_fopen is set to true or false in your php.ini (call phpinfo() to determine).
 
here is the code simplified.

<?php
header('Content-type: image/jpeg');
$filename = $_POST['url'];
$image = imagecreatefromjpeg($filename);
imagejpeg($image,null,80);
imagedestroy( $image );
?>

$filename in there gets a URL of an image on another server. The two servers are both linux. one thing i noticed with the url is that it is a public url. allow_url_fopen is also set On.


thanks for any reply..
 
Are you sure your not using the $_GET[]?
Does it produce any errors?

Windows versions of PHP prior to PHP 4.3.0 do not support accessing remote files via this function, even if allow_url_fopen is enabled.

Olav Alexander Mjelde
Admin & Webmaster
 
if you call the url natively, do you get the image in your browser?
 
hello guys.

i am using PHP5 on a linux server. i even tried directly assigning the url in the code. $filename = ' still it didnt work... i tried local files and yes it worked. i can see the image.
 
i just tried using a native url call and it didnt work as well... now this is giving me headaches.
 
but what could be the possible cause for this? when i use ipaddress in local files, i can access the image. but when i use the public url, it can't read any...

pls help me...
 
it is not a php problem. it will be something to do with the configuration of the web server, which is out of scope of this forum (we don't even know which web server you are using).

your best bet is to talk to the webmaster of the relevant server.
 
thanks a lot. at least i knew that this is not php related.

thanks.
 
may i ask one more thing... what is the requirement for using imagecreatefromjpeg? does the image have to be writeable? does the folder containing the image have to be writeable?

pls do reply...

thanks a lot.
 
no - readable only. hence my question as to whether you could grab the image remotely using http.
 
yes i could access the url in browser... i dont know but i just found out that i can only access pictures on this web server. i cant see all the others on a different server...
 
how do you set user_agent? and what does it do? im new to that...
 
feherke

you could be right but I had assumed that both servers were under the OP's control. also, why would the webserver reject requests to a particular url but not via IP address? possible but it would be a very odd set up, no?
 
jpadie

i can't access any image on another server whether using ip address or hostname. all i can access are images deployed on this same web server...

but i can ping the other's. this is what makes everything weirder...
 
then i am sure feherke is right - this will be a referer test or some other issue.

what is the identity of the foreign web server? maybe we can test it for you.
 
it is a lan connected environment... what should i do with feherke's suggestion? guidance is really needed...
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top