上传脚本正常运行,文件也会以正确/所需的名称保存。但是,在将数据存储在数据库中时,它会存储.tmp文件名
控制器代码:
public function store(CreateChapterRequest $request)
{
if($request['chapter_content_type']==6) {
//upload file
$record_save = $this->processFile($request->file('chapter_document'));
$request['chapter_document']=$record_save;
}
Chapter::create($request->all());
}
protected function processFile($requestData)
{
$input['chapter_document'] = time().'.'.$requestData->getClientOriginalExtension();
$destinationPath = public_path('uploads/chapters/');
$requestData->move($destinationPath, $input['chapter_document']);
return $input['chapter_document'];
}
它将文件名存储为C:\project\xampp\tmp\phpD837.tmp
。怎么了?
答案 0 :(得分:0)
适用于$record=new Chapter(); $record->save($request->all());
,但不适用于::create()
不知道为什么!