3.2 - 严重 - 未处理
如果先$upload = new \Think\Upload();
后,再
$upload->rootPath = './MyUploads/';
如果没有建./Uploads/目录是通不过checkRootPath()验证的,因为Upload类59行__construct的时候
$this->setDriver($class, $driverConfig);
而249行
$this->uploader = new $class($this->rootPath, $config);
的时候传入了$this->rootPath,Local类中checkRootPath()的时候验证的是31行构造时的$this->rootPath
因此,如果自己改变了上传根目录的话只能用实例化传入的方式:
$config = array(
'rootPath' => 'MyUploads/',
);
$upload = new \Think\Upload($config);另,手册中实例化传入的部分有错误$config = array(
'maxSize' = 3145728,
'savePath' = './Public/Uploads/',
'saveName' = array('uniqid',''),
'exts' = array('jpg', 'gif', 'png', 'jpeg'),
'autoSub' = true,
'subName' = array('date','Ymd'),
);
$upload = new \Think\Upload($config);// 实例化上传类应为:$config = array(
'maxSize' => 3145728,
'savePath' => './Public/Uploads/',
'saveName' => array('uniqid',''),
'exts' => array('jpg', 'gif', 'png', 'jpeg'),
'autoSub' => true,
'subName' => array('date','Ymd'),
);
$upload = new \Think\Upload($config);// 实例化上传类 