如何使用Laravel Framework中的cURL PHP从svn(https站点)下载文件?

如何使用Laravel Framework中的cURL PHP从svn(https站点)下载文件?

问题描述:

I created login using cURL to this site "https://svn.logicgenie.com:8090/svn/" and displayed only file names in it. Now i need to download particular file from SVN. How can i do that? Please help me with the codes.

I used this cURL Script:

$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');

The url used, to download file is "https://svn.logicgenie.com:8090/svn/cheapssls/trunk/admin.php". Only the file name "admin.php" is getting open. It is not working with some other file name or link . What would be the problem? Please do help me.

我使用cURL创建登录到此站点“ https://svn.logicgenie.com:8090/svn/ ”并在其中仅显示文件名。 现在我需要从SVN下载特定文件。 我怎样才能做到这一点? 请帮我处理这些代码。 p>

我使用了这个cURL脚本: p>

  $ 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');  //没有缓存
header('Cache-Control:must-revalidate,post-check = 0,pre-check = 0'); 
header('Last-Modified:'。gmdate('D,d MYH: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));  //提供文件大小
header('Connection:close'); 
  code>  pre> 
 
 

用于下载文件的URL是“ https://svn.logicgenie.com:8090/svn/cheapssls/trunk/admin.php “ 。 只有文件名“admin.php”才会打开。 它不能与其他文件名或链接一起使用。 会出现什么问题? 请帮帮我。 p> div>

If you want to download a file from SVN repository you just have to checkout the file from the repository. By default, you wont have a directory tree on the remote repository, on the svn repository there aren't any /trunk/path/to/something, so you have to checkout in order to obtain some file.

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

This command will get your file. If you want to obtain your file without history or SVN files, just make:

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

Hope it helps!