我正在尋找這方面的一些一般指導...如何設置PHP將文件下載到特定目錄?
我已經創建了一個PHP腳本,使用cURL下載一個csv文件。目前,當我運行腳本時,它將文件下載到我的電腦。我想修改下載路徑將其路由到我的虛擬主機上的目錄。有沒有簡單的方法來做到這一點與PHP?
下面是PHP腳本的簡單總結說下載的CSV文件:
<?php
$ch = curl_init();
//this is where I submit the form to download the csv file...
curl_close ($ch);
header("Content-Disposition: attachment; filename=file_I_am_downloading.csv");
header("Content-Type: application/octet-stream");
readfile("http://www.example.com/file_I_am_downloading.csv");
?>
總結這件事,我想腳本進行修改,這樣,當我運行這個PHP文件,它下載「 file_I_am_downloading.csv'到主機上的特定目錄,而不是先下載到我的電腦。感謝您的時間和任何方向,你可以提供非常感謝。
如果您fopen封裝使您可以簡單地使用PHP copy命令:http://php.net/manual/en/function.copy.php – JohnP