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使用