1.问题,项目中上传文件使用插件时,windows上支持函数exif_imagetype(),而在linux上不支持。

2.PHP exif_imagetype的本质

PHP exif_imagetype note #1
Windows users: If you get the fatal error "Fatal error:  Call to undefined function exif_imagetype()", and you have enabled php_exif.dll, make sure you enable php_mbstring.dll. You must put mbstring before exif in the php.ini, i.e.:extension=php_mbstring.dll
extension=php_exif.dll

You can check whether this has worked by calling phpinfo() and searching for exif.
PHP exif_imagetype note #2
If the function exif_imagetype() is not available,
you can try the following workaround:if ( ! function_exists( 'exif_imagetype' ) ) {function exif_imagetype ( $filename ) {if ( ( list($width, $height, $type, $attr) = getimagesize( $filename ) ) !== false ) {return $type;}return false;}
}
PHP exif_imagetype note #3
By trial and error, it seems that a file has to be 12 bytes or larger in order to avoid a "Read error!".  Here's a work-around to avoid an error being thrown:// exif_imagetype throws "Read error!" if file is too small
if (filesize($uploadfile) > 11)$mimetype = exif_imagetype($uploadfile);
else$mimetype = false;
PHP exif_imagetype note #4
Seems to give a 'Read error' warning if the size of the file is very small (2 bytes). I think this is because it needs a min 3 bytes to determine the file type
PHP exif_imagetype note #5
libexif can also be used to parse image info out of id3 tags:exif_read_data("mp3_with_2.4ID3TAGS, '', true, false);
PHP exif_imagetype note #6
After looking for hours, I found a very good source for exif related programs here: http://drewnoakes.com/code/exif/index.html
It lists exif specifications (pdf), a few good links to exif related stuff. The best source I have found in my quest to understand exif better for use in php based exif tools.

3.解决方案:

  if ( ! function_exists( 'exif_imagetype' ) ) {

          // $currFile = $file['tmp_name'];          list($width, $height, $type2, $attr) = getimagesize($file['tmp_name']);           $type = $type2;          // function exif_imagetype ($currFile) {          //   if ( ( list($width, $height, $type2, $attr) = getimagesize($currFile) ) !== false ) {          //       // return $type;          //     $type = $type2;          //   }          //   return false;          // }        }else{           // $type = exif_imagetype($src);          $type = exif_imagetype($file['tmp_name']);        }

转载于:https://www.cnblogs.com/wuheng1991/p/6641187.html

exif_imagetype() 函数在linux下的php中不存在相关推荐

  1. stol函数在linux下使用,C++中进制转换问题

    <Python核心编程> 18.多线程编程(一) 一进程和线程 1参考链接: http://www.zhihu.com/question/25532384 中OF小工和zhonyong 的 ...

  2. Linux下在程序中如何进行繁体中文和简体中文的转换

    此文章转自他人,只是为了方便自己整理资料以及大家共同进步而发布. 转载自: http://hi.baidu.com/runningon/item/7acd387eddb5aa346cc37ce4 Li ...

  3. php文件内含有隐藏的^m字符,【整理】如何取消Linux下,vi中显示的^M符号

    [整理]如何取消Linux下,vi中显示的^M符号 [背景知识] ^M 是ascii中的'\r', 回车符,是16进制的0x0D,8进制的015,十进制的13. 对于换行这个动作,unix下一般只有一 ...

  4. Linux下高性能网络编程中的几个TCP/IP选项

    Linux下高性能网络编程中的几个TCP/IP选项 转自:http://blog.chinaunix.net/u/12592/showart.php?id=2064847 最近在新的平台上测试程序,以 ...

  5. Linux下CMake工程中gtestgmock的安装与使用

    Linux下CMake工程中gtest&gmock的安装与使用 gtest和gmock是什么和功能以及用法可参考以下两篇文章,都相当给力! gtest <玩转Google开源C++单元测 ...

  6. windows和linux通用的压缩,如何在linux下实现Windows中winrar和winzip等压缩软件所提供的打包压缩分割功能?...

    (如何在linux下实现Windows中winrar和winzip等压缩软件所提供的打包压缩分割功能) 将大文件或目录打包.压缩并分割成制定大小的文件,这在将数据备份到容量有限的移动储存设备时是必须的 ...

  7. linux中c语言kbhit函数用法,linux下kbhit()函数 getch函数。

    对于上面的问题,都用到 linux下的getch函数与kbhit函数. 参考了http://kpld8888.wordpress.com/2007/03/07/linux%E4%B8%8B%E7%9A ...

  8. Linux下HOOK动态链接库中API的方法

    2012年,我写了一篇介绍Windows系统下Ring3层API的hook方案--<一种注册表沙箱的思路.实现--Hook Nt函数>,其在底层使用了微软的Detours库.5年后,我又遇 ...

  9. Linux下gcc编译中关于头文件与库文件搜索路径相关问题

    如何指定GCC的默认头文件路径 网上偶搜得之,以之为宝:) 原地址:http://blog.chinaunix.net/u/28781/showart.php?id=401631 ========== ...

最新文章

  1. OpenCV+python:膨胀和腐蚀
  2. 趋势型指标——MACD
  3. windows下安装awstats来分析apache的访问日志
  4. a类不确定度计算器_统统帮您搞定:LIMS系统,换版、内审、期间核查、不确定度、数据分析…………...
  5. 前端小白第一次使用redux存取数据练习
  6. Android应用安全之Content Provider安全
  7. centos7 /etc/profile 文件模板
  8. asp.net js 提示信息封装函数
  9. QT + MinGW 中文显示乱码解决方案
  10. 动态分享到微信朋友圈的方法,果断收藏——(摘抄至他人)
  11. python模型预测结果 取整_一日一技:Python里面的//并不是做了除法以后取整
  12. Spark性能优化指南——高级篇【2】
  13. 基于matlab的音频处理论文,基于Matlab的语音信号处理与仿真设计毕业论文
  14. 投资理财之基金篇(一) - 认识基金
  15. 这有10款好玩游戏,游戏迷速来围观
  16. 7E3 Banding
  17. Java IDEA的使用
  18. 《第一篇》快学Flink-实时读取socket
  19. Discuz!教程之门户列表页文章中无图片时,从图库中选择一张作为封面
  20. Au 效果器详解:响度计

热门文章

  1. hadooppythonudf_Hive使用python编写的自定义函数UDF进行ETL
  2. oracle:oracle学习笔记(四)循环、光标、异常、瀑布模型
  3. maven package install deploy区别
  4. sourcetree 推送找不到bash.exe_找旅伴 | 周末轻旅行
  5. 【clickhouse】ClickHouse表引擎 MergeTree 数据生命周期
  6. Google Guice 一个轻量级的依赖注入框架
  7. 95-241-100-源码-Flink语义-Flink的exectly-once系列之两阶段提交概述
  8. 【Siddhi】Flink Siddhi自定义函数
  9. 【Maven】Maven classifier的作用
  10. Spring : Spring Aop JDK动态代理调用过程