當前位置:編程學習大全網 - 網站源碼 - 用php程序自動讀取遠程文件並更新到本地,每天壹次,如何做?

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

.....

....

....

>

  • 上一篇:只讀源代碼
  • 下一篇:如何把chm文件轉換成word文件,或轉換成txt文件?
  • copyright 2024編程學習大全網