2014-12-02 112 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