PHP to achieve bulk download Baidu Cloud Disk File example sharing

Source: Internet
Author: User
Tags mkdir

  This article uses Baidu Open cloud PHP SDK to achieve bulk download Baidu cloud disk files, need friends can refer to.  

Baidu Open Cloud phpsdk download Address: http://developer.baidu.com/wiki/index.php?title=%E5%B8%AE%E5%8A%A9%E6%96%87%E6%A1%A3%E9%A6%96% e9%a1%b5/web%e5%ba%94%e7%9 4%a8%e6%8e%a5%e5%85%a5/sdk   Instance code:     Code as follows: <?php/**  * Author: HANKCS  * Date &nbsp: 14-3-29  * time  : Afternoon 10:29  */ini_set ("Max_execution_time", 36000); Require_once '.. /bcs.class.php '; Require_once '.. /krumo/class.krumo.php '; $host = ' bcs.duapp.com '; $ak = ' Your public key '; $sk = ' your private key '; $bucket = ' bucket name to download '; $baidu _bcs = new Baidubcs ($ak, $sk, $host);   $response = Json_decode ($baidu _bcs->list_object ($bucket, Array (' Start ' => 0, ' limit ' => 1024,))->bod y); $downloaded _size = 0; while ($downloaded _size < $response->object_total) {    Krumo ($response)    //download them   &NB Sp foreach ($response->object_list as $object)     {        if (! $object->is_dir)   & nbsp     {            Mk_Dir ('. ') $object->parent_dir);             $result = $baidu _bcs->get_object ($bucket, $object->object, Array ("Filew Riteto "=> '." $object->object));        }     {    $downloaded _size + = count ($response->object_list);     $response = Json_decode ($baidu _bcs->list_object ($bucket, Array (' Start ' => $downloaded _size, ' Limit ' => 1024,))->body); }   function Mk_dir ($dir, $mode = 0755) {    if (Is_dir ($dir) | | @mkdir ($DIR, $mode)) return true;   & nbsp if (!mk_dir (DirName ($dir), $mode)) return false;     return @mkdir ($dir, $mode); }  

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.