2014-12-02 42 views
0

我使用cURL登錄到本網站「https://svn.logicgenie.com:8090/svn/」,並僅顯示文件名。現在我需要從SVN下載特定的文件。我怎樣才能做到這一點?請幫我編碼。如何使用cURL PHP在Laravel Framework中從svn(https站點)下載文件?

我用這個捲曲腳本:

$url = "https://svn.logicgenie.com:8090/svn/cheapssls/trunk/admin.php"; 
set_time_limit(0); 
$ch = curl_init(); 
curl_setopt($ch, CURLOPT_URL, $url); 
curl_setopt($ch, CURLOPT_USERPWD, "firstuser:welcome"); 
curl_setopt($ch, CURLOPT_FOLLOWLOCATION, true); 
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true); 
curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, 0); 
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, 0); 
$r = curl_exec($ch); 
echo $r; 
curl_close($ch); 
header('Expires: 0'); // no cache 
header('Cache-Control: must-revalidate, post-check=0, pre-check=0'); 
header('Last-Modified: ' . gmdate('D, d M Y H:i:s', time()) . ' GMT'); 
header('Cache-Control: private', false); 
header('Content-Type: application/force-download'); 
header('Content-Disposition: attachment; filename="' . basename($url) . '"'); 
header('Content-Transfer-Encoding: binary'); 
header('Content-Length: ' . strlen($r)); // provide file size 
header('Connection: close'); 

使用的URL,下載文件是 「https://svn.logicgenie.com:8090/svn/cheapssls/trunk/admin.php」。只有文件名「admin.php」正在打開。它不適用於其他文件名或鏈接。會有什麼問題?請幫助我。

回答

1

如果你想從SVN資源庫中下載文件,你只需要檢查存儲庫中的文件。默認情況下,你不會在遠程倉庫上有一個目錄樹,在svn倉庫中沒有任何/ trunk/path/to/something,所以你必須簽出才能獲得一些文件。

$svn co http://path/to/your/file nameForYourFile 

該命令將獲得您的文件。如果你想獲得你的文件沒有歷史或SVN文件,只需:

$svn export http://path/to/your/file nameForYourFile 

希望它有幫助!

+0

我試圖使用cURL PHP代碼從svn倉庫下載文件。這裏的命令是什麼?我在哪裏放?幫助我的PHP代碼。 – 2014-12-04 06:20:48