I trying to force to download a remote image (url with https protocol), I failed to attempts do it on client (cannot use HTML5, thanks to IE8), so I'm trying to use server side (php). The only way how to do it I found thanks following answer, is using curl. Other way like readfile($file_url), always return an empty file. The problem with using curl - downloading starts after image is downloaded to server and it can take some time. Can we start loading directly from the source?

But if somebody know a way how to download an image on client side, that already on the page, it will be great!

有帮助吗?

解决方案

You can use fopen('http://server/img.jpg'), and fread():

$handle = fopen("http://www.example.com/image.jpg", "rb");
while (!feof($handle)) {
  echo fread($handle, 8192);
}
fclose($handle);

plus headers.

许可以下: CC-BY-SA归因
不隶属于 StackOverflow
scroll top