drzrdc1766788 2014-12-02 07:39
浏览 67

如何使用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.

  • 写回答

1条回答 默认 最新

  • dongxianrang9269 2014-12-03 15:24
    关注

    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!

    评论

报告相同问题?

悬赏问题

  • ¥15 求daily translation(DT)偏差订正方法的代码
  • ¥15 js调用html页面需要隐藏某个按钮
  • ¥15 ads仿真结果在圆图上是怎么读数的
  • ¥20 Cotex M3的调试和程序执行方式是什么样的?
  • ¥20 java项目连接sqlserver时报ssl相关错误
  • ¥15 一道python难题3
  • ¥15 牛顿斯科特系数表表示
  • ¥15 arduino 步进电机
  • ¥20 程序进入HardFault_Handler
  • ¥15 关于#python#的问题:自动化测试