下载upload类,将解压后extend文件夹里的文件复制到thinkphp框架的extend文件夹里;
具体代码如下:
Loader::import('org.upload.driver.Local.php'); //引入扩展upload类
Loader::import('org.Upload.php');
$config = [ //设置上传参数
'maxSize' => 3145728,
'exts' => ['imsclt'],
'autoSub' => false,
'subName' => ['date', 'Y-m-d'],
'rootPath' => './uploads/',
'savePath' => '',
'saveName' => time().'_'.mt_rand(),
'replace' => true,
'saveExt' => 'imsclt',
'hash' => true,
'callback' => true,
'driver' => 'Local',
];
$upload=new Upload($config);
$info=$upload->upload();
if(!$info)
{
echo $upload->getError();
}
else
{
echo 'success';
}