zoukankan      html  css  js  c++  java
  • tp5.1 获取原始上传文件名

    打印一下上传的文件对象可以的得出,大致对象结构如下

    object(thinkFile)#77 (13) {
      ["error":"thinkFile":private] => string(0) ""
      ["filename":protected] => string(14) "/tmp/phpkIAvIy"
      ["saveName":protected] => NULL
      ["rule":protected] => string(4) "date"
      ["validate":protected] => array(0) {
      }
      ["isTest":protected] => NULL
      ["info":protected] => array(5) {
        ["name"] => string(10) "ebrima.ttf"
        ["type"] => string(24) "application/octet-stream"
        ["tmp_name"] => string(14) "/tmp/phpkIAvIy"
        ["error"] => int(0)
        ["size"] => int(907232)
      }
      ["hash":protected] => array(0) {
      }
      ["pathName":"SplFileInfo":private] => string(14) "/tmp/phpkIAvIy"
      ["fileName":"SplFileInfo":private] => string(9) "phpkIAvIy"
      ["openMode":"SplFileObject":private] => string(1) "r"
      ["delimiter":"SplFileObject":private] => string(1) ","
      ["enclosure":"SplFileObject":private] => string(1) """
    }
    

    看这结构,访问权限是protected,如何获取呢?

    获取方法:

    对象->getInfo() 获取info属性

    //对象->getInfo() 获取info属性,['name']  获取name的值
    $file->getInfo()['name']
    
  • 相关阅读:
    代码编译时JDK版本和运行时JDK版本不一致启动项目报错
    Apache 环境变量配置
    Android NDK 环境变量配置
    Android SDK 环境变量配置
    JAVA 环境变量配置
    FFmpeg Download
    JAVA SE Download
    VS 2015 Download
    BASS HOME
    C++11的闭包(lambda、function、bind)
  • 原文地址:https://www.cnblogs.com/makalochen/p/13163343.html
Copyright © 2011-2022 走看看