我正在尝试下载一个安全的图像,我可以下载除以下链接以外的其他图像。
下面是我的代码:
<?php
function downloadFile ($url, $path) {
$newfname = $path;
$file = fopen ($url, "rb");
if ($file) {
$newf = fopen ($newfname, "wb");
if ($newf)
while(!feof($file)) {
fwrite($newf, fread($file, 1024 * 8 ), 1024 * 8 );
}
}
if ($file) {
fclose($file);
}
if ($newf) {
fclose($newf);
}
}
downloadFile ("https://store.bbcomcdn.com/images/store/skuimage/sku_EVL4900077/image_skuEVL4900077_largeImage_X_450_white.jpg", "name.jpg");
?>https://stackoverflow.com/questions/51414845
复制相似问题