打印一下上传的文件对象可以的得出,大致对象结构如下
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']