php远程下载
㈠ php怎么把远程图片通过api接口传到另外一个站点上
本地传图片到服务器叫上传,服务器从别的网站获取图片,这叫下载,这比上传还简单
$content = file_get_contents(图片地址);
file_put_contents(保存的路径文件名, $content);
㈡ 用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程序自动读取远程文件并更新到本地,每天一次,如何做
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:
<?php
require_once("fileGeter.php");
//and so on .....
.....
....
....
?>
㈣ php代码保存远程图片到本地,出现重复建立文件夹,是怎么回事出现嵌套建立文件夹
没用过php,但如果出现这个问题就一定是if(file_exists($fname))判断出的错,试试将
$fname='yong/'.$id;改成
$fname='/yong/'.$id;试试看
或者要检查的话,就在if(file_exists($fname)){ 上面加一行输出一下file_exists($fname)看看每次判断的结果。
㈤ thinkphp怎样下载远程服务器上的文件
PclZip下载这个包,配合thinkphp使用