У меня есть API для хранения изображений в папке и в БД, когда я пытаюсь проверить API с помощью Postman, он всегда возвращает «не удалось открыть поток: нет такого файла или каталога в файле», пожалуйста, помогите мне.Спасибо.
Контроллер:
$path = base_path('storage/app/public/profile/');
$base = $request->picture;
$binary = base64_decode($base);
header('Content-Type: bitmap; charset=utf-8');
$f = finfo_open();
$mime_type = finfo_buffer($f, $binary, FILEINFO_MIME_TYPE);
$mime_type = str_ireplace('image/', '', $mime_type);
$filename = md5(\Carbon\Carbon::now()) . '.' . $mime_type;
$file = fopen($path . $filename, 'wb'); "this line throws that error"
if (fwrite($file, $binary)) {
$user = User::find(auth()->id());
$user->profile_image = 'profile/' . $filename;
$user->save();
return response()->json(array('result' => "yes"));
} else {
return response()->json(array('result' => "no"));
}
fclose($file);