[英]Get xls file mime type using php
I have xls
file (From ms ecxel -> save as -> workbook excel 97-2003) 我有
xls
文件(从ms ecxel->另存为->工作簿Excel 97-2003)
Then I upload this file on server using php, this is my code: 然后我使用php将文件上传到服务器上,这是我的代码:
$finfo = finfo_open(FILEINFO_MIME_TYPE);
$type = finfo_file($finfo, $_FILES['file_name']['tmp_name']);
echo $type;
result is: application/msword
结果是:
application/msword
Why this happened? 为什么会这样? As I know
xls
file type is application/vnd.ms-excel
据我所知
xls
文件类型是application/vnd.ms-excel
Put this in your htaccess file on the root of your site: 将其放在网站根目录下的htaccess文件中:
AddType application/vnd.ms-excel xls
This should allow apache to recognize xls file formats as a distinct format. 这应该允许apache将xls文件格式识别为不同的格式。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.