PHP PHP下载/复制文件/图像
Posted
tags:
篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了PHP PHP下载/复制文件/图像相关的知识,希望对你有一定的参考价值。
function download($file_source, $file_target)
{
// prepare
$file_source = str_replace(' ', '%20', html_entity_decode($file_source)); // fix url format
if (file_exists($file_target)) chmod($file_target, 0777); // add write permission
// opne files
if (($rh = fopen($file_source, 'rb')) === FALSE) return false; // fopen() handles
if (($wh = fopen($file_target, 'wb')) === FALSE) return false; // error messages.
// read & write
while (!feof($rh))
{
if (fwrite($wh, fread($rh, 1024)) === FALSE)
{
// unable to write to file, possibly
// because the harddrive has filled up
fclose($rh);
fclose($wh);
return false;
}
}
// close files
fclose($rh);
fclose($wh);
return true;
}
以上是关于PHP PHP下载/复制文件/图像的主要内容,如果未能解决你的问题,请参考以下文章