0

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?

Alexey
  • 7,127
  • 9
  • 57
  • 94

3 Answers3

2

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

$im = imagecreatefrompng('drupal/BBcode.png');
scessor
  • 15,995
  • 4
  • 43
  • 54
0

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');
risyasin
  • 1,325
  • 14
  • 24
0

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.

johannes
  • 15,807
  • 3
  • 44
  • 57