【发布时间】:2014-01-19 16:48:45
【问题描述】:
我只想上传图片,文档说使用 finfo_open。 http://www.php.net/manual/en/function.finfo-file.php
我这样做了,但我得到了这个错误:
致命错误:调用未定义的函数 finfo_open() C:\xampp\htdocs\ticket\index.php 第 83 行调用堆栈
时间记忆函数位置 1 2.2551 158752 {main}( ) ..\index.php:0
PHP:
if(isset($_FILES['file'])) {
$finfo = finfo_open(FILEINFO_MIME_TYPE);
$ext = finfo_file($finfo, $_FILES['file']['name']); << LINE 84
if(substr($ext, 0, 5) != 'image') {
$errors[] = 'Kon dit bestand type niet uploaden.';
}
}
为什么这不起作用?
更新:
通过设置 extension=php_fileinfo.dll active 我现在明白了:
警告:finfo_file(download.jpg):打开流失败:没有这样的文件 或 C:\xampp\htdocs\ticket\index.php 中的目录第 84 行调用堆栈
时间记忆函数位置 1 2.2531 158448 {main}( ) ..\index.php:0 2 3.2572 180560 finfo_file ( ) ..\index.php:84
【问题讨论】:
-
finfo_open 需要 PHP >= 5.3.0
-
我有:PHP 版本 5.4.7
-
检查 php.ini fileinfo.so 是否处于活动状态