简体   繁体   English

Laravel在数据库中存储临时文件名

[英]Laravel storing temporary filename in database

The upload script is working, the file also gets saved by the correct/desired name. 上载脚本正在运行,文件也将使用正确/所需的名称进行保存。 However, while storing data in database, it stores .tmp filename instead 但是,在将数据存储在数据库中时,它而是存储.tmp文件名。

controller code: 控制器代码:

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'];
}

It's storing file name as C:\\project\\xampp\\tmp\\phpD837.tmp . 它将文件名存储为C:\\project\\xampp\\tmp\\phpD837.tmp What's wrong? 怎么了?

It works with $record=new Chapter(); $record->save($request->all()); 它与$record=new Chapter(); $record->save($request->all()); $record=new Chapter(); $record->save($request->all()); but not with ::create() 但不能使用::create()

Don't know why! 不知道为什么!

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM