大佬教程收集整理的这篇文章主要介绍了使用php在服务器之间传输文件,大佬教程大佬觉得挺不错的,现在分享给大家,也给大家做个参考。
Hello I wrote a little code in PHP that enables me to download a file from one website to my own! but there is a little problem here! I can only Download files from my website that are less than 4MB:( Now my question is that in what way I can Download special part of files from other websites! like from 1st byte to 10th byte! And second question is how to get file Information before starTing Download! (I want files size for downloading)
http://www.polarpengi.gigfa.com/code.htm
解决方法:
function downloadFileFromUrl($url, $dstFilepath) {
$fr = @fopen($url, 'r');
if($fr === falsE) {
throw new Primage_Proxy_Storage_sourceNotFound($url);
}
$fw = fopen($dstFilepath, 'w');
if($fw === falsE) {
throw new Exception('WriTing to file "' . $dstFilepath . '" Failed');
}
$timeLimit = 1000;
set_time_limit($timeLimit);
$deadline = time() + 1000;
while(!feof($fr)) {
$bufferString = fread($fr, 10000);
fwrite($fw, $bufferString);
if($deadline - time() < 10) {
fclose($fw);
fclose($fr);
unlink($dstFilepath);
throw new Primage_Proxy_Storage_sourceNotFound($url);
}
}
fclose($fw);
fclose($fr);
}
以上是大佬教程为你收集整理的使用php在服务器之间传输文件全部内容,希望文章能够帮你解决使用php在服务器之间传输文件所遇到的程序开发问题。
如果觉得大佬教程网站内容还不错,欢迎将大佬教程推荐给程序员好友。
本图文内容来源于网友网络收集整理提供,作为学习参考使用,版权属于原作者。
如您有任何意见或建议可联系处理。小编QQ:384754419,请注明来意。