How to make a copy of a text file that located in another server
How to make a c开发者_运维问答opy of a text file that located in another server , in php
There are two ways that I can immediately think of:
file_put_contents('/my/path/file.txt', file_get_contents('http://www.example.org/test.txt'));
See the file_get_contents()
and file_put_contents()
manual pages.
Or more succinctly:
copy('http://www.example.org/test.txt', '/my/path/file.txt')
See the copy()
manual page.
Of course do not forget:
A URL can be used as a filename with this function if the fopen wrappers have been enabled.
See the allow_url_fopen
manual page for more information.
copy('http://yourdomine.com/souce.txt','your/path.txt')
Should work.
you could use file_get_contents()
and file_put_contents()
I think you have to read the remote file and write it into yours:
$f = fopen('myfile.txt','w');
fwrite($f, file_get_contents('http://www.example.com/myfile.txt'));
fclose($f);
精彩评论