我正在从另一个站点获取用户的个人资料图片。我想为具有图像URL的用户创建一个文件夹。因为每个用户的个人资料图片都必须在其自己的文件中。这就是我要做的。我正在使用自定义工匠命令。
foreach ($adminUser as $user) {
$a= DB::table('users')->where('email', $user['email'])->first();
if($a) {
echo "\n ", $a->name, " this user already exists. \n";
continue;
} else {
$a = User::create($user);
echo "\n ", $user['name'], " created. \n";
if (isset($user['link']) && strlen($user['link']) > 0) {
$folder_Path = public_path().'/user_images/' . $a->id;
File::makeDirectory($folder_Path, $mode = 0777, true, true);
$contents = file_get_contents($user['link']);
$file_name = basename($user['link']);
Storage::disk('uploads')->put($file_name, $contents);
$this->info(" |--> Profile picture uploaded.");
}
}