国产av日韩一区二区三区精品,成人性爱视频在线观看,国产,欧美,日韩,一区,www.成色av久久成人,2222eeee成人天堂

php隱藏實(shí)際地址的文件下載方法

Original 2017-02-04 10:51:06 341
abstract:本文實(shí)例講述了php隱藏實(shí)際地址的文件下載方法。分享給大家供大家參考。具體如下:下面這段php代碼可不透露實(shí)際的文件下載地址。function download_document($filename,$path="",$mimetype="application/octet-stream") {  header("Cache-C

本文實(shí)例講述了php隱藏實(shí)際地址的文件下載方法。分享給大家供大家參考。具體如下:

下面這段php代碼可不透露實(shí)際的文件下載地址。

function download_document($filename,$path="",$mimetype="application/octet-stream")
{
 header("Cache-Control: must-revalidate, post-check=0, pre-check=0");
 header("Content-Disposition: attachment; filename = $filename");
 header("Content-Length: " . filesize($pathto . $filename));
 header("Content-Type: $mimetype");
 echo file_get_contents($pathto . $filename);
}

實(shí)現(xiàn)方法二:

<?php
$file = "1.txt";// 文件的真實(shí)地址(支持url,不過(guò)不建議用url)
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, post-check=0, pre-check=0');
  header('Pragma: public');
  header('Content-Length: ' . filesize($file));
  ob_clean();
  flush();
  readfile($file);
  exit;
}
?>

更多關(guān)于php隱藏實(shí)際地址的文件下載方法請(qǐng)關(guān)注PHP中文網(wǎng)(m.miracleart.cn)其他文章!   


Release Notes

Popular Entries