使用ThinkPHP 6内置文件上传方法时
总共封装三种方式 MD5 sha1 date,
其他俩种都是正常使用,唯独date使用时会报错
代码如下
$savename = \think\facade\Filesystem::disk('public')->putFile('topic', $file,'date');
print_r($savename);die;
报错如下
使用ThinkPHP 6内置文件上传方法时
总共封装三种方式 MD5 sha1 date,
其他俩种都是正常使用,唯独date使用时会报错
代码如下
$savename = \think\facade\Filesystem::disk('public')->putFile('topic', $file,'date');
print_r($savename);die;
报错如下
默认的就是date规则的:
$file = request()->file('file);
$path = "path";
$saveName = Filesystem::disk('public')->putFile($path, $file, function () use ($file) {
switch (true) {
case "date":
$fileName = date('YmdHis') . '_' . rand(1000,9999);
break;
default:
$fileName = "自定义名称";
break;
}
return $fileName;
});