Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
我需要我的服务器下载文件并将其写入服务器的文件系统。问题是我见过的所有 PHP 示例都将文件下载到服务器 RAM 中,然后写入文件。
由于我正在处理大文件,我希望 PHP 从其他服务器读取文件并立即将它读取的内容写入本地文件。
像这样使用curl:
curl
<?php $url = 'http://www.example.com/a-large-file.zip'; $path = '/path/to/a-large-file.zip'; $fp = fopen($path, 'w'); $ch = curl_init($url); curl_setopt($ch, CURLOPT_FILE, $fp); $data = curl_exec($ch); curl_close($ch); fclose($fp); ?>