I am accessing images from another website. I am getting "failed to open stream: HTTP request failed! HTTP/1.1 400 Bad Request " error when copying 'some(not all)' images. here is my code.

$img=$_GET['img']; //another website url
$file=$img;

function getFileextension($file) {
       return end(explode(".", $file));
}
$fileext=getFileextension($file);
if($fileext=='jpg' || $fileext=='gif' || $fileext=='jpeg' || $fileext=='png' || $fileext=='x-png' || $fileext=='pjpeg'){
if($img!=''){
$rand_variable1=rand(10000,100000);
              $node_online_name1=$rand_variable1."image.".$fileext;

                $s=copy($img,"images/".$node_online_name1);
}

i am copying images from another site. when ever copy function executes then i am getting this error. Warning: copy(http://www.xyz.com/store/images/uploads/2009 /RIBDI018 fancy blue white diamond ring.jpg) [function.copy]: failed to open stream: HTTP request failed! HTTP/1.1 400 Bad Request in /home/content/22/7101122/html/getimage.php on line 17

Recommended Answers

All 7 Replies

Are you sure you're allowed to copy those images ?

yes....i am allowing to copy. some images are copying but some are getting this error.

There are some other copy functions in the manual's comments. Do those fail as well ? However, I still think the server is blocking your copy.

i have a small doubt...why this error occurs?

thanks.

i m facinng during my files this error http/1.1 400. plz help me to sort this. thanks

If you read the previous link, you may get some indication of what are possible causes. If yo uneed more help, please start a new thread and provide more info on what you have done, and what software you are running.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.