【php下载远程文件类(支持断点续传)_php技巧】教程文章相关的互联网学习教程文章

php获取远程网页内容简单函数

$curDomain = $_SERVER['HTTP_HOST']; $strHTML = file_get_contents('http://bbs.it-home.org/DomainParking.asp?gDomName='.$curDomain); echo $strHTML ?>file_get_contents不稳定。 碰到错误: file_get_contents(http://***.php): failed to open stream: HTTP request failed! 此处建议采用curl方式。 >>> 您可能感兴趣的文章: php curl采集站外内容示例代码 php curl参数详解与用法大全 php Curl抓取远程内容出现url中文...

php获取远程图片大小函数示例

//用法 echo remote_filesize($url,$user=,$pw=);$url = "http://www.aa.com/librarys/images/random/rand_11.jpg";//图片地址echo remote_filesize($url,$user=,$pw=);function remote_filesize($uri,$user=,$pw=){// start output buffering ob_start();// initialize curl with given uri $ch = curl_init($uri); // make sure we get the header curl_setopt($ch, CURLOPT_HEADER, 1); // make it a http HEAD reques...

php下载获取远程图片函数(可伪造来路)

//下载获取远程图片 function DownImageKeep($gurl, $rfurl, $filename, $gcookie="", $JumpCount=0, $maxtime=30) { $urlinfos = GetHostInfo($gurl); $ghost = trim($urlinfos['host']); if($ghost=='') { return FALSE; } $gquery = $urlinfos['query']; if($gcookie=="" && !empty($rfurl)) { $gcookie = RefurlCookie($rfurl); } $sessionQuery = "GE...

PHP获取(读取)本地文件与远程文件内容示例

$file = 'jbxue.com.php'; //不支持远程 $fso = fopen($file, 'r'); echo $data = fread($fso, filesize($file)); fclose($fso); ?>fopen() 将 file 指定的名字资源绑定到一个流上. filesize 返回文件大小的字节数,如果出错返回 FALSE. 注: 因为 PHP 的整数类型是有符号的,并且大多数平台使用 32 位整数,filesize() 函数在碰到大于 2GB 的文件时可能会返回非预期的结果.对于 2GB 到 4GB 之间的文件通常可以使用 sprintf("%u", fi...

PHP获取远程网页内容(fopen,curl方式)【图】

$handle = fopen ("http://bbs.it-home.org/", "rb"); $contents = ""; while (!feof($handle)) { $contents .= fread($handle, 8192); } fclose($handle); echo $contents; //输出获取到得内容。 ?>// 对 PHP 5 及更高版本可以使用下面的代码 $handle = fopen("http://bbs.it-home.org", "rb"); $contents = stream_get_contents($handle); fclose($handle); echo $contents; ?>以上代码容易出现 failed to open stream: HTTP req...

php模拟远程登录示例代码

<?php!extension_loaded(curl) && die(the curl extension is not loaded.); $baseurl = http://127.0.0.1;//根地址 $login_url = $baseurl ./login.php?act=login;//登录页地址 $get_url = $baseurl ./index.php; //需要采集的页面 $post_fields = array(); //以下两项需要修改 $post_fields[name] = admin; $post_fields[pass] = 123456; //获取表单formhash $ch = curl_init($login_url); curl_seto...

php下载远程图片函数示例(伪造来路)

/*** @功能:下载远程图片* @ bbs.it-home.org*/ function DownImageKeep($gurl, $rfurl, $filename, $gcookie="", $JumpCount=0, $maxtime=30) { $urlinfos = GetHostInfo($gurl); $ghost = trim($urlinfos['host']); if($ghost=='') { return FALSE; } $gquery = $urlinfos['query']; if($gcookie=="" && !empty($rfurl)) { $gcookie = RefurlCookie($rfurl); ...

php获取远程图片url生成缩略图的方法

/** **函数:调整图片尺寸或生成缩略图 *返回:True/False *参数:* $Image 需要调整的图片(含路径) * $Dw=450 调整时最大宽度;缩略图时的绝对宽度 * $Dh=450 调整时最大高度;缩略图时的绝对高度 * $Type=1 1,调整尺寸; 2,生成缩略图 */ bbs.it-home.org$phtypes=array('img/gif', 'img/jpg', 'img/jpeg', 'img/bmp', 'img/pjpeg', 'img/x-png'); function compressImg($Image,$Dw,$Dh,$Type){ IF(!file_exists...

php函数抓取远程图片到本地

<?php//php ob函数库抓取远程图片function GetImage($url, $filename = "") {if ($url == "") {return false;}if ($filename == "") {$ext = strrchr ( $url, "." );if ($ext != ".gif" && $ext != ".jpg") {return false;}$filename = time () . $ext;}//文件 保存路径ob_start ();readfile ( $url );$img = ob_get_contents ();ob_end_clean ();$size = strlen ( $img );//文件大小$fp2 = @fopen ( $filename, "a" );fwrite ( $f...

为帮母亲而写的PHP远程访问chrome书签的程序~【图】

母亲有时会上网逛一下网店,有喜欢或需要的东西就用chrome收藏起来,我回来后帮她拍下付费。如何浏览到她收藏的东西是个问题,如果去她电脑上操作,需要登录用户,装安全控件啥啥的弄一大堆,而且我喜欢先在米折上折一下,再买。再加上她电脑有点慢,每次都要弄半天。想了想,写了个简单的程序。可以远程和本地访问chrome收藏文件。程序我打包放网盘了,请各位老师批评指正:http://pan.baidu.com/s/1pJ18ZYb程序用php开发,使用流...

远程图片获取到本地(音频、视频也行)【图】

远程图片获取到本地(音频、视频也行) , 不能是特殊加密的function GrabImage($url,$filename="") { if($url==""):return false;endif; if($filename=="") { $ext=strrchr($url,"."); if($ext!=".gif" && $ext!=".jpg"):return false;endif; $filename_r=time().rand(10,9000).$ext; $filename=get_images/.$filename_r; } ob_start(); readfile($url); $img = ob_get_contents(); ob_end_clean(); $size = strlen($i...

php实用获取远程图片的通用方法

function auto_save_image($body){ $img_array = explode(&,$body); /*$img_array = array(); preg_match_all("/(src)=[\"|\| ]{0,}(http:\/\/(.*)\.(gif|jpg|jpeg|bmp|png))[\"|\| ]{0,}/isU", $body, $img_array); $img_array = array_unique($img_array[2]);*/ //也可以自动匹配 set_time_limit(0); $imgPath = "uploads/allimg/".date("Ymd")."/"; $milliSecond = strftime("%H%M%S",time()); if(!is_dir($imgPath)) @mkdir($i...

支持断点续传的PHP下载远程文件类

PHP 下载远程文件类,支持断点续传下载,代码内含有具体的调用说明。程序主要是使用 HTTP 协议下载文件,HTTP1.1协议必须指定文档结束后关闭链接,否则读取文档时无法使用feof判断结束,可以有两种使用方法,具体请下载查看源码。 /** * 下载远程文件类支持断点续传 */class HttpDownload { private $m_url = ""; private $m_urlpath = ""; private $m_scheme = "http"; private $m_host = ""; private $m_port = "8...

PHP防止站外远程提交表单的例子

在进行php开发(http://www.maiziedu.com/course/php/)时,为了防止站长提交表单无非就是对每一次打开表单或提交数据都会需要加一个token来进行验证了,这个其实与验证码做法没什么两样了,下面来看几个防止站外远程提交表单的例子。 例子一:我们每一次打开提交页面生成一个token然后保存在session中,当表单提交时我们来判断当前的token值与session是否一致,如果是的就是正常提交否则就是无效提交了。 具体代码如下: if ($_PO...

一个读取远程文件的PHP函数

一个读取远程文件的函数,非常好用! function urlfopen($url, $limit = 0, $post = , $cookie = , $bysocket = FALSE , $ip = , $timeout = 15, $block = TRUE, $encodetype = URLENCODE) { $return = ; $matches = parse_url($url); $host = $matches[host]; $path = $matches[path] ? $matches[path].(isset($matches[query]) ? ?.$matches[query] : ) : /; $port = !empty($m...