Alexey
Alexey

Reputation: 7247

imagecreatefrompng() failed to open stream: HTTP request failed

On my local host this code works well:

$im = imagecreatefrompng('BBcode.png');

But when I use the same code in the server

$im = imagecreatefrompng('http://lazertag.elitno.net/drupal/BBcode.png');

I got the folloowing error:

Warning: imagecreatefrompng(http://lazertag.elitno.net/drupal/BBcode.png) [function.imagecreatefrompng]: failed to open stream: HTTP request failed! HTTP/1.1 403 Forbidden in /www/elitno.net/l/a/lazertag/home/site/drupal/renderImage.php on line 46

How do I solve this?

Upvotes: 0

Views: 7270

Answers (3)

scessor
scessor

Reputation: 16115

If the file is on your server, use a (relative) system path, not an url: E.g.:

$im = imagecreatefrompng('drupal/BBcode.png');

Upvotes: 2

johannes
johannes

Reputation: 15969

403 Forbidden means that the server blocked you from accessing the file. you can try doing a file_get_contents("http://...."); do get an error message, maybe the creator's of the site put one in place else you have to talk to them.

Upvotes: 0

risyasin
risyasin

Reputation: 1321

Before using imagecreate, can you download remote image into a local folder then work on it ?!

your ex:

$imagefile = file_get_contents('http://lazertag.elitno.net/drupal/BBcode.png');
$fp  = fopen('./BBcode.png', 'w+'));
fputs($fp, $imagefile);
fclo$fp);
unset($imagefile);
$im = imagecreatefrompng('./BBcode.png');

Upvotes: 0

Related Questions