我的html名称:
<input type="file" value="" name="postmeta[featured_image]">
我的dd($request->files->all())
所以,我的行动应该在以下之后开始:
if ($request->hasFile('postmeta')) {
// How do I can handle files request with nested files values here?
}
答案 0 :(得分:1)
我找到了解决方案:
首先,在表单中打开标签dnt,忘记启用multipart / form-data:
{!! Form::open(['action'=>'PostsController@update', 'files' => true]) !!}
最后:
if ($request->hasFile('postmeta')) {
$files = $request->file('postmeta');
foreach ( $files as $file_key => $file ) {
if($file->isValid()) {
$filedata = [
'ext' => $file->getClientOriginalExtension(),
'mime' => $file->getClientMimeType(),
'name' => $file->getClientOriginalName(),
'size' => $file->getClientSize(),
'error' => $file->getError(),
'valid' => $file->isValid()
];
$file->move(public_path().'/uploads', "uploaded_".$filedata['name']);
}
}
}