下载文件到本地

35次阅读

共计 358 个字符,预计需要花费 1 分钟才能阅读完成。

<?php
function saveImage($path) {if(!preg_match('/\/([^\/]+\.[a-z]{3,4})+\?.*?$/i',$path,$matches))
 die('Use image please');
 $image_name = strToLower($matches[1]);
 $img = file_get_contents($path);
 $fp = fopen($image_name,'w');
 fwrite($fp, $img);
 fclose($fp);
 //unlink($image_name);
}
saveImage('http://img.v2.shunliandev.com/uploads/20200415/20200415141847617v.png?w=750&h=350');

正文完
 0