javascript - 微信公众号里如何实现 点击下载 的功能,服务器端为php
ringa_lee
ringa_lee 2017-04-11 10:45:36
0
1
294
ringa_lee
ringa_lee

ringa_lee

membalas semua(1)
PHPzhong

不需要Ajax 直接<a href='http://example.com/test.doc' download>下载</a>

或者点击链接,php下载

$file  =  'test.doc' ;

if ( file_exists ( $file )) {
     header ( 'Content-Description: File Transfer' );
     header ( 'Content-Type: application/octet-stream' );
     header ( 'Content-Disposition: attachment; filename=' . basename ( $file ));
     header ( 'Content-Transfer-Encoding: binary' );
     header ( 'Expires: 0' );
     header ( 'Cache-Control: must-revalidate' );
     header ( 'Pragma: public' );
     header ( 'Content-Length: '  .  filesize ( $file ));
     ob_clean ();
     flush ();
     readfile ( $file );
    exit;
}
Muat turun terkini
Lagi>
kesan web
Kod sumber laman web
Bahan laman web
Templat hujung hadapan
Tentang kita Penafian Sitemap
Laman web PHP Cina:Latihan PHP dalam talian kebajikan awam,Bantu pelajar PHP berkembang dengan cepat!