我想更新用户图像,但是没有更新。
我尝试使用$request->hasFile('image')
,但是当我返回这些语句时,它总是返回false
这是我的控制器
if($request->hasFile('image'))
{
$file = $request->file('image');
$file->move(public_path().'/image/',$file->getClientOriginalName());
$file_name = $file->getClientOriginalName();
DB::table('settings')
->where('id', $id)
->update(['logo' => $file_name]);
}
我写的时候
return response()->json($request->hasFile('image'));
它将始终返回false
答案 0 :(得分:0)
尝试改用这个
const arr = [{"Title" : 'test',"Format" : "BLA-BLA","Start Year" : '2012',"Stars" : []},{"Title" : 'test2',"Format" : "BLA-BLA2","Start Year" : '2032',"Stars" : []}]
const keyMapper = {
"Title" : "name",
"Format" : "format",
"Start Year" : "year",
"Stars" : "actors"
}
const final = arr.map(val => {
return Object.entries(val).reduce((op,[key,value]) => {
op[keyMapper[key]] = value
return op
},{})
})
console.log(final)