中文字幕在线观看,亚洲а∨天堂久久精品9966,亚洲成a人片在线观看你懂的,亚洲av成人片无码网站,亚洲国产精品无码久久久五月天

php處理文件下載的代碼

2018-07-20    來源:open-open

容器云強(qiáng)勢上線!快速搭建集群,上萬Linux鏡像隨意使用

用在服務(wù)器上提供下載的php代碼,可以指定被下載的文件名,可以動態(tài)指定文件內(nèi)容

// local file that should be send to the client
$local_file = 'test.zip';
// filename that the user gets as default
$download_file = 'your-download-name.zip';
 
if(file_exists($local_file) && is_file($local_file)) {
    // send headers
    header('Cache-control: private');
    header('Content-Type: application/octet-stream'); 
    header('Content-Length: '.filesize($local_file));
    header('Content-Disposition: filename='.$download_file);
 
    // flush content
    flush();
 
    /*
    ** You can also remove the following part and
    ** replace it trough a database command fetching 
    ** the download data
    */
    // open file stream
    $file = fopen($local_file, "rb");
 
    // send the file to the browser
    print fread ($file, filesize($local_file)); 
 
    // close file stream
    fclose($file);}
else {
    die('Error: The file '.$local_file.' does not exist!');
}

標(biāo)簽: isp 代碼 服務(wù)器

版權(quán)申明:本站文章部分自網(wǎng)絡(luò),如有侵權(quán),請聯(lián)系:west999com@outlook.com
特別注意:本站所有轉(zhuǎn)載文章言論不代表本站觀點(diǎn)!
本站所提供的圖片等素材,版權(quán)歸原作者所有,如需使用,請與原作者聯(lián)系。

上一篇:利用imagick庫把PDF轉(zhuǎn)成PNG格式的PHP代碼

下一篇:Java 通過FTP 上傳文件的簡單例子