簡體   English   中英

如何在Laravel Framework中使用cURL PHP從svn(https站點)下載文件?

[英]How to download files from svn (https site) using cURL PHP in Laravel Framework?

我使用cURL創建了到該站點“ https://svn.logicgenie.com:8090/svn/ ”的登錄名,並僅在其中顯示文件名。 現在,我需要從SVN下載特定文件。 我怎樣才能做到這一點? 請幫助我的代碼。

我使用了以下cURL腳本:

$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”打開。 它無法使用其他文件名或鏈接。 有什么問題嗎? 請幫幫我。

如果要從SVN儲存庫下載文件,只需從儲存庫中檢出文件。 默認情況下,您在遠程存儲庫上沒有目錄樹,在svn存儲庫上沒有任何/ trunk / path / to / something,因此您必須簽出以獲得一些文件。

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

此命令將獲取您的文件。 如果要獲取沒有歷史記錄或SVN文件的文件,只需進行以下操作:

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

希望能幫助到你!

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM