找回密码
 注册
【阿里云】2核2G云服务器新老同享 99元/年,续费同价,云服务器3年机/5年机限时抢购,低至 2.5折华为云精选云产品特惠糖果主机Jtti,新加坡服务器,美国服务器,香港服务器,海外云服务器
查看: 2641|回复: 12

free.fr上传大文件方法

[复制链接]
发表于 2011 年 7 月 16 日 20:42:20 | 显示全部楼层 |阅读模式

马上注册,结交更多好友,享用更多功能,让你轻松玩转社区。

您需要 登录 才可以下载或查看,没有账号?注册

×
用fsockopen来远程下载文件,虽然会500错误,但是不会超时,文件会一直下载完成为止!
测试代码如下:
  1. <?php
  2. /****
  3. Powerd by haowenq
  4. Form www.jgwy.net
  5. 2011.7.16
  6. ****/
  7. $url="http://dbdown.2u.com.cn/system/ylmf_GHOSTXP_SP3V2010.8.iso";
  8. $fileName = basename($url);
  9. $urlParts = parse_url($url);
  10. $socketHandler = fsockopen($urlParts["host"], 80, $errno, $errstr, 30);
  11. if (!$socketHandler) {
  12.         exit("Connet error!");
  13. } else {
  14.         if (file_exists($fileName)) {
  15.                 $from = filesize($fileName);
  16.         }
  17.         $out = "GET ".$urlParts["path"]." HTTP/1.0\r\n";
  18.         $out .= "Accept: */*\r\n";
  19.         $out .= "Accept-Language: en-us\r\n";
  20.         $out .= "User-Agent: Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.1; SV1)\r\n";
  21.         $out .= "Host: ".$urlParts["host"]."\r\n";
  22.         $out .= "Connection: Close\r\n";
  23.         $out .= "Cache-Control: no-cache\r\n\r\n";
  24.         $headerFound = false;
  25.         if (!$fileHandler = fopen($fileName, "a")) {
  26.                 exit("Can not open file!");
  27.         }
  28.         fwrite($socketHandler, $out);
  29.         while (!feof($socketHandler)) {
  30.                 if ($headerFound) {
  31.                                 $result = fread($socketHandler, 8192);
  32.                                 if (fwrite($fileHandler, $result) === false) {
  33.                                         exit("Can not save file!");
  34.                                 }
  35.                 } else {
  36.                         $result = fgets($socketHandler, 8192);
  37.                         $result = trim($result);
  38.                         if ($result === "") {
  39.                                 $headerFound = true;
  40.                         }
  41.                 }
  42.         }
  43.         fclose($fileHandler);
  44.         fclose($socketHandler);
  45.         echo "Well done!";        
  46. }
  47. ?>
复制代码
运行之后,本目录会多一个文件“ylmf_GHOSTXP_SP3V2010.8.iso”,下载完成之后大小为699.43 M!
附件同以上代码!

haowenq.zip (761 Bytes, 下载次数: 267)
Jgwy.Com - Free Web Hosting Guide & Directory In China since 2001! Jgwy.Net-Jglt.Net
发表于 2011 年 7 月 16 日 21:20:28 | 显示全部楼层
【腾讯云】2核2G云服务器新老同享 99元/年,续费同价
可以用不?
Jgwy.Com - Free Web Hosting Guide & Directory In China since 2001! Jgwy.Net-Jglt.Net
回复

使用道具 举报

发表于 2011 年 7 月 16 日 21:26:56 | 显示全部楼层
牛逼,膜拜
Jgwy.Com - Free Web Hosting Guide & Directory In China since 2001! Jgwy.Net-Jglt.Net
回复

使用道具 举报

发表于 2011 年 7 月 16 日 21:28:08 | 显示全部楼层
对于会超时,超内存的空间可以用断点续传。

点评

如何断点续传啊?望指教  发表于 2011 年 7 月 18 日 20:26
Jgwy.Com - Free Web Hosting Guide & Directory In China since 2001! Jgwy.Net-Jglt.Net
回复

使用道具 举报

发表于 2011 年 7 月 16 日 21:32:24 | 显示全部楼层
此办法可行,已经测试
Jgwy.Com - Free Web Hosting Guide & Directory In China since 2001! Jgwy.Net-Jglt.Net
回复

使用道具 举报

发表于 2011 年 7 月 16 日 23:45:38 | 显示全部楼层
不错啊!
LZ的那个管理面板可否共享下呀。{:soso_e100:}
Jgwy.Com - Free Web Hosting Guide & Directory In China since 2001! Jgwy.Net-Jglt.Net
回复

使用道具 举报

发表于 2011 年 7 月 17 日 00:43:19 | 显示全部楼层
【腾讯云】2核2G云服务器新老同享 99元/年,续费同价
高 实在是高
Jgwy.Com - Free Web Hosting Guide & Directory In China since 2001! Jgwy.Net-Jglt.Net
回复

使用道具 举报

发表于 2011 年 7 月 17 日 00:51:24 来自手机 | 显示全部楼层
cckkk 发表于 2011-7-16 21:32 此办法可行,已经测试

请你别那个别人送给我的小号折磨行不
Jgwy.Com - Free Web Hosting Guide & Directory In China since 2001! Jgwy.Net-Jglt.Net
回复

使用道具 举报

发表于 2011 年 7 月 17 日 00:51:47 来自手机 | 显示全部楼层
cckkk 发表于 2011-7-16 21:32 此办法可行,已经测试

请你别那个别人送给我的小号折磨行不
Jgwy.Com - Free Web Hosting Guide & Directory In China since 2001! Jgwy.Net-Jglt.Net
回复

使用道具 举报

发表于 2011 年 7 月 17 日 08:38:37 | 显示全部楼层
这个东东不错。

直接WGET
Jgwy.Com - Free Web Hosting Guide & Directory In China since 2001! Jgwy.Net-Jglt.Net
回复

使用道具 举报

您需要登录后才可以回帖 登录 | 注册

本版积分规则

Archiver|手机版|小黑屋|金光论坛

GMT+8, 2024 年 9 月 20 日 09:27 , Processed in 0.105473 second(s), 23 queries .

Powered by Discuz! X3.5

© 2001-2023 Discuz! Team.

快速回复 返回顶部 返回列表