php下载远程文件|php 如何下载远程文件到本地重命名

php下载远程文件|php 如何下载远程文件到本地重命名的第1张示图

❶ 用php程序自动读取远程文件并更新到本地,每天一次,如何做

windows: 准备: 1.将 php.exe 的路径加入 windows 的环境变量 2.编写文件: D:\fileGeter.php<?php $filelist = Array( "http://**********/a.txt", "http://**********/b.txt", ); $saveas="D:\\" ; $endl = ".txt" function getfile(){ foreach( $filelist as $k => $file ) file_put_contents( $saveas . $k . $endl , file_get_contents( $file ) ) ; } getfile(); ?> 3.执行cmd命令 at 11:20 /every:1,2,3,4,5,6,7 "php D:\fileGeter.php"linux 更方便 直接把此文件包含进 你要写的程序里就OK了,fileGeter.php:<?php……$saveas = "./";…..?>index.php:<?phprequire_once("fileGeter.php");//and so on ………………?>

❷ php include 能包含远程文件吗

可以,但是需要修改配置程序。具体如下:最好检查一下php.ini中的配置选项allow_url_include,如果为on则可以包含,否则不能包含; Whether to allow include/require to open URLs (like http:// or ftp://) as files.allow_url_include = Off做个简单的测试,此时allow_url_include的值为Off测试前配置一下hosts文件,这样可以在一台电脑上面进行模拟测试192.168.1.101 www.test1.com192.168.1.102 www.test2.compath.php文件内容为:<?phpecho "This is file path.php<br />\n";include("http://www.test2.com/research/path/path.php");?>path1.php文件内容为:<?phpecho "This is file path1.php in root directory\n";?>执行http://www.test1.com/research/path/path.php,输出如下This is file path.phpWarning: include() [function.include]: URL file-access is disabled in the server configuration in E:\myphp\research\path\path.php on line 3Warning: include(http://www.test2.com/research/path/path.php) [function.include]: failed to open stream: no suitable wrapper could be found in E:\myphp\research\path\path.php on line 3Warning: include() [function.include]: Failed opening 'http://www.test2.com/research/path/path.php' for inclusion (include_path='.;C:\php5\pear') in E:\myphp\research\path\path.php on line 3将php.ini中的allow_url_include改为On,重新启动web服务器,再次执行http://www.test1.com/research/path/path.php,输出如下:This is file path.phpThis is file path1.php in root directory 将allow_url_include设为On以后,就可以包含远程文件了,并且包含的是远程文件执行的结果。

❸ php 如何下载远程文件到本地重命名

给你一个思路: 1.使用文件读取函数 (注意问题:当文件很大时有可能会断掉。)2.重新保存在你想要的位置就行了。

❹ 用php如何获取远程的xls表格文件地址,并将它下载到本地

写段伪代码给你:

//先获取远程网页的源代码$html=file_get_contents(http://mp3..com/歌曲播放页.html);//用正则表达式分析源内代码中的资源链接容$link=preg_match_all(正则)…//读取资源文件$bin=file_get_contents(http://mp3..com/时间都去哪了.mp3);//保存资源文件到本地$fp=fopen(时间都去哪了.mp3,wb)$fp.writh($bin);$fp.close();

先说好,不要让我写完整的源代码,因为这里还涉及一些细节,比如说,你才提供的 xls ,就是需要登录的,那么你还要实现模拟登录。

有些网站的资源链接有各种限制,需要你慢慢去深入。

❺ PHP下载远程图片jpg 格式,

<?phpheader("Content-type:application/octet-stream");header("Accept-Ranges:bytes");header("Accept-Length:".filesize($path));header("Content-Disposition:attachment;filename=".basename($path));readfile($path);?>

❻ 急求PHP源码,能够远程下载其他网站的文件并保存到自己网站的目录里或者指定目录,谢谢高手!

可以很负责人的告诉你 没有 要下载其他网站的文件,只能下载如RAR HTML等文件,不能下载ASP PHP JSP等脚本文件

❼ php 异步实现远程下载

jquery的load就可以异步了

❽ php有没有在服务器上从远程url下载的功能

$filename=basename($url);//取文件名源$getfile = @file_get_contents($url);$arr_file = @explode("/",$url);foreach($arr_file as $value){$filename =$value;//保存文件名+后缀名} if(@!is_dir($folders)){//判断目录不存在则建立 make_file($folder);} [email protected]("$folder/$filename",'w+');//建立文件 fwrite($file,$getfile);//写入文件$file= str_replace(ROOT_PATH, '',($folder."/".$filename));return $file; fclose($file);

❾ php curl get 下载远程zip文件保存在本地例子

<?phpif($_POST['submit']){$url=$_POST['url']; //取得提交过来的地址http://hu60.cn/wap/0wap/addown.php/fetion_sms.zip$url=urldecode($url);$fname=basename("$url"); //返回路径中的文件名部分 fetion_sms.zip$str_name=pathinfo($fname); //以数组的形式返回文件路径的信息$extname=strtolower($str_name['extension']); //把扩展名转换成小写//$uptypes=explode(",",$forum_upload); //取得可以上传的文件格式//$size=getFileSize($url);$time=date("Ymd",time());$upload_dir="./upload/";//上传的路径$file_name=$time.rand(1000,9999).'.'.$fname;$dir=$upload_dir.$file_name;//创建上传目录//判断目录是否存在 不存在则创建if(!file_exists($upload_dir)){mkdir($upload_dir,0777,true);}$contents=curl_download($url,$dir);if($contents){echo "下载成功";}else{echo "下载失败";}}function curl_download($url, $dir) {$ch = curl_init($url);$fp = fopen($dir, "wb");curl_setopt($ch, CURLOPT_FILE, $fp);curl_setopt($ch, CURLOPT_HEADER, 0);$res=curl_exec($ch);curl_close($ch);fclose($fp);return $res;}?><!DOCTYPE html><html lang="zh-CN"><head><meta><meta charset="utf-8" /><meta name="viewport" content="width=device-width, initial-scale=1"><title>远程下载文件</title><form name="upform" method="post" action="" enctype='multipart/form-data'> <input name='url' type='text' size='20'/> <input type='submit' name='submit' value='远程下载'/></form></body></html>

未经允许不得转载:山九号 » php下载远程文件|php 如何下载远程文件到本地重命名

赞 (0)