无法在Laravel 5数据库中保存多个图像

时间:2015-09-03 06:53:14

标签: php mysql laravel laravel-5

我有一个名为<div ng-bind-html="connection.LikeCountMessage" class="ng-binding"> <span class="ui-like ">You and 4 other like this</span> </div> 的表格,其中"casescolumn idimage1content1image2content2 3和image

当我从表单提交时,我的content3将保存在数据库中,但图像既不保存在文件夹中也不保存在数据库中。我需要帮助

控制器

content1,content2,content3

查看/形式

                                         

public function store(Request $request,SidContainRequest $request)
    {
        $sidContain = new sidcontain;

        $sidContain->content1 = $request->get('page_content1');
        $sidContain->content2 = $request->get('page_content2');
        $sidContain->content3 = $request->get('page_content3');

        //upload multiple files 
        $files= [];

        if($request->file('leftimage'))   $files[] = $request->file('leftimage');
        if($request->file('Middleimage')) $files[] = $request->fiel('Middleimage');
        if($request->file('Rightimage'))  $files[] = $request->file('Rightimage');

          foreach($files as $flle)
          {
             if(!empty($file))
             {
                $filename[] = $file->getClientOrginalName();
                if(isset($filename)){
                $file->move(base_path().'/frontend/sidimage/',end($filename));
           }
       }
        $sidContain->image1 = $filename[0];
        $sidContain->image2 = $filename[1];
        $sidContain->image3 = $filename[2];





        }

        $ok = $sidContain->save();
        if($ok)
        {
            \Session::flash('flash_message','Report Added Successfully!');
            return Redirect::to('administrator/sidConatin/create');
        }
    }

0 个答案:

没有答案