我找到了用户注册的功能:
public function postRegister(Request $request)
{
$validator = $this->validator($request->all());
if ($validator->fails()) {
$this->throwValidationException(
$request, $validator
);
}
Auth::login($this->create($request->all()));
File::makeDirectory('/images/'.Auth::user()->id);
return redirect($this->redirectPath());
}
但是可以创建名为$ user-> id的文件夹inisde图像文件夹,以便创建像/ images / 1这样的文件夹
我尝试
$result = File::makeDirectory('/images/'.Auth::user()->id);
但没有成功
我也试试:
$directory = public_path().'\images'.Auth::user()->id;
File::makeDirectory($directory);
但我再也看不到文件夹...
有没有办法在用户注册
上的public / images / user-> id中创建文件夹答案 0 :(得分:2)
将递归设置为true作为第三个参数尝试:
File::makeDirectory(public_path().'/images/'.Auth::user()->id, 0755, true);
答案 1 :(得分:1)
确保在laravel中使用File facade,您可以执行以下操作:
use File;
File::makeDirectory(base_path("/images/".Auth::user()->id), 0755, $recursive = true, $force = false);
或:
use File;
File::makeDirectory(base_path("/images/".Auth::user()->id), 0755, true);