如何将文件下载到服务器PHP? [英] How to download a file to server PHP?
问题描述
PHP脚本是否可以让脚本将远程服务器上的文件下载到我的Web服务器?
Is it possible with PHP script to have the script download a file on a remote server to my web server?
我有自己的Web服务器和域。我想在该域放置一个php脚本,这将从远程服务器将文件下载到我的服务器的文件系统上。这可能吗?
I have my own webserver and domain. I want to put a php script on that domain, that will download a file from a remote server onto my server's filesystem. Is this possible?
-Jim
推荐答案
当然,你需要写权限文件系统的某处(您要保存此文件的位置), file_get_contents
可以使用URL作为参数,您只需将生成的字符串写入新文件
Sure, you'll need write permissions somewhere on the file system (where you want to save this file), file_get_contents
can take a URL as its argument, you just need to write the resulting string to a new file
我个人通过调用shell并调用 wget
或类似于我在一个linux框上的方式来执行此操作。
I'd personally do this by calling out to the shell and invoking wget
or similar if i were on a linux box.
这篇关于如何将文件下载到服务器PHP?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!