PHP implements direct download of Baidu online storage

Source: Internet
Author: User
Provides various official and user-released code examples. For code reference, you are welcome to exchange and learn the thinkphp video tutorials recently downloaded! I saw thinkphp use a Baidu online drive for direct download, and I think it is very good! Using Baidu's powerful server to upload content from your website to Baidu, and then directly download the content from your website, which is required by many webmasters.
/* Save this code as bd. php.

Use the file_get_contents, preg_match_all, and str_replace functions!

Add the $ Region ID and $ uk of the Baidu online storage.
Example: http://pan.baidu.com/share/link? Consumer id = 489412 & uk = 101682133

Localhost/bd. php on your server? Upload id = 489412 & uk = 101682133 and you can download it by yourself.
*/
$ Region ID = $ _ GET ['region id'];
$ Uk = $ _ GET ['uk '];

If (isset ($ Region ID) & isset ($ uk ))
{
$ Str = file_get_contents ("http://pan.baidu.com/share/link? Consumer id = {$ consumer ID} & uk = {$ uk }");

Preg_match_all ('| "dlink \": \ "([^"] +) \ ", \" | imsU', $ str, $ baiduid );
$ Down = str_replace ("\", "", $ baiduid [1] [1]);

}



Header ("Location:". $ down );

?>

AD: truly free, domain name + VM + enterprise mailbox = 0 RMB

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.