Pergunta

i am using this function to copy an image from a given url.

i am getting this error:

Warning: imagecreatefromjpeg(http://preview.netcarshow.com/Ford-Focus_RS500-2011-hd.jpg): failed to open stream: HTTP request failed! HTTP/1.0 403 Forbidden in /var/www/clients/client2/web3/web/process/updatebuildinfo.php on line 68 Warning: imagejpeg() expects parameter 1 to be resource, boolean given in /var/www/clients/client2/web3/web/process/updatebuildinfo.php on line 69 Warning: imagedestroy() expects parameter 1 to be resource, boolean given in /var/www/clients/client2/web3/web/process/updatebuildinfo.php on line 70 AdminCraig,376http://preview.netcarshow.com/Ford-Focus_RS500-2011-hd.jpg

The code im using is this:

$imagefile = $_POST['updatebuildcover'];
$resource = imagecreatefromjpeg($imagefile);
imagejpeg($resource, "images/covers/$imagepath.jpeg", 25);
imagedestroy($resource);
echo $imagepath;
echo $imagefile;

The image path is a string thats created earlier on, and as you can see when i echo both of the $imagefile and the path they are working fine.

I have used this exact code before and worked fine.

Any ideas on whats causing this?

Foi útil?

Solução

It seems that the destination website (preview.netcarshow.com) is rejecting your GET request, as you can see the HTTP 403 status code:

HTTP/1.0 403 Forbidden

This is an HTTP error thrown by the web server.

Maybe the mentioned web server reject the download from automated scripts?

Licenciado em: CC-BY-SA com atribuição
Não afiliado a StackOverflow
scroll top