黑龙码

thinkphp5 获取上传图片的大小和信息

晓峰 时间:2019-05-25 14:35:08 阅读:2635
--------------------------------------------------------- Ta 只分享的内容开始 ---------------------------------------------------------------------

thinkphp5 获取上传图片的大小和信息


先看一下打印出对象信息如下。

object(think\File)#19 (13) {
  ["error":"think\File":private] => string(0) ""
  ["filename":protected] => string(77) "E:\WWW\im_liaosp\public\uploads\20180620\e4c230cf5432223ea1f28a7b31b44ac7.png"
  ["saveName":protected] => string(45) "20180620/e4c230cf5432223ea1f28a7b31b44ac7.png"
  ["rule":protected] => string(4) "date"
  ["validate":protected] => array(0) {
  }
  ["isTest":protected] => NULL
  ["info":protected] => array(5) {
    ["name"] => string(31) "0180620202751.png"
    ["type"] => string(9) "image/png"
    ["tmp_name"] => string(21) "D:\phptmp\phpB7C3.tmp"
    ["error"] => int(0)
    ["size"] => int(48182)
  }
  ["hash":protected] => array(0) {
  }
  ["pathName":"SplFileInfo":private] => string(56) "./uploads/\20180620/e4c230cf5432223ea1f28a7b31b44ac7.png"
  ["fileName":"SplFileInfo":private] => string(36) "e4c230cf5432223ea1f28a7b31b44ac7.png"
  ["openMode":"SplFileObject":private] => string(1) "r"
  ["delimiter":"SplFileObject":private] => string(1) ","
  ["enclosure":"SplFileObject":private] => string(1) """
}


获取信息使用这个即可   $fileobj->getInfo();


$info = $fileobj->getInfo();

array(5) {
  ["name"] => string(31) "20180620202751.png"
  ["type"] => string(9) "image/png"
  ["tmp_name"] => string(21) "D:\phptmp\gongfuma.tmp"
  ["error"] => int(0)
  ["size"] => int(48182)
}


--------------------------------------------------------- Ta 只分享了这些内容 ---------------------------------------------------------------------

本文来源:黑龙码(gongfuma.com.cn)
声明:本文系黑龙码原创稿件,版权属[黑龙码 gongfuma.com.cn]所有。
未经授权不得转载,已经协议授权的媒体下载使用时须注明"稿件来源:黑龙码",违者将依法追究责任。

相关文章

  • 回到顶部