【发布时间】:2012-08-07 09:13:14
【问题描述】:
我想下载一个远程文件并将其放在我的服务器目录中,并与原始文件具有相同的名称。我尝试使用file_get_contents($url)。
问题是文件名不包含在$url 中,就像:www.domain.com?download=1726。这个网址给我,例如:myfile.exe,所以我想用file_put_contents('mydir/myfile.exe');。
如何检索文件名?下载前我试过get_headers(),但我只有文件大小、修改日期等信息,文件名不见了。
【问题讨论】:
-
看看 cURL 它应该能满足你的需求php.net/manual/en/book.curl.php
-
看这个问题的cURL文件名stackoverflow.com/questions/1750055/…
标签: php file header file-get-contents remote-server