php 利用Fileinfo 获取文件MIME类型(finfo_open) 下载
2014-04-23 01:59
676 查看
<?php include "function.php"; $file = $_GET['tag']; // header("Content-type:application/octet-stream");//二进制文件 // $fileName = basename($file);//获得文件名 // header("Content-Disposition:attachment;filename={$fileName}");//下载窗口中显 示的文件名 // header("Content-ranges:bytes");//文件尺寸单位 // header("Content-length:".filesize($file));//文件大小 // readfile($file);//读出文件内容 $finfo = finfo_open(FILEINFO_MIME_TYPE); $mimetype = finfo_file($finfo, $file); finfo_close($finfo); $file = basename($file); header("Content-Type: $mimetype"); //指明文件是那个类型的 header("Content-Disposition: attachment; filename={$file}");//下载窗口显示的文件名 header("Expires: 0"); header("Content-Transfer-Encoding: binary"); header("Pragma: no-cache"); header("Content-Length:".filesize($file)); readfile($file);//读出文件内容 ?>
$finfo = finfo_open(FILEINFO_MIME);$mimetype = finfo_file($finfo, $filename);finfo_close($finfo);
例子
相关文章推荐
- php获取文件mime类型Fileinfo等方法
- PHP Fileinfo获取文件MIME类型
- 利用 hadoop 的 FileSystem open 方法获取 FSDataInputStream 实现文件下载到本地 Hadoop 版本 2.7.0
- php 获取文件mime类型的方法
- 利用WinAPI(GetFileVersionInfo)获取文件版本信息
- 获取文件图标,类型名称,属性 SHGetFileInfo
- 利用WinAPI(GetFileVersionInfo)获取文件版本信息
- php获取文件mime类型的几种方法
- php 获取 mime type 类型,fileinfo扩展
- php获取文件mime类型的几种方法
- php实现获取文件mime类型的方法
- 获取文件类型使用 finfo_file 内置函数
- php准确获取文件MIME类型的方法
- 【MoreWindows工作笔记4】 获取文件图标,类型名称,属性 SHGetFileInfo
- php准确获取文件MIME类型的方法
- php实现获取文件mime类型的方法
- php 获取文件mime类型的方法
- php获取文件mime类型的几种方法
- ajax利用FormData、FileReader实现多文件上传php获取
- <input type="file">定义样式并获取上传文件路径及指定文件类型