Bhavik Hirani Bhavik Hirani - 1 month ago 5
PHP Question

Get Image With file_get_contents it return Not Found Error

I have one Image on another server (Image).but when i get this image With

function it will return

Not Found Error

and generate this Image.

file_put_contents(destination_path, file_get_contents(another_server_path));

plz help me. if there are another way to get those image.


Try this.

There is problem with URL Special character.then you have to decode some special character from url basename.

$imgfile = ' fr 137 group.jpg';
$destinationPath = '/path/to/folder/';
$filename = basename($imgpath);
$imgpath = str_replace($filename,'',$imgpath).rawurldecode($filename);