php - larvael5.4 file upload error
ringa_lee
ringa_lee 2017-06-30 09:56:37
0
1
781

Controller code:

public function doUpload(Request $request)
    {
        //判断是否是一个有效上传文件
         if ($request->input('picname') && $request->input('picname')->isValid()) {
            //获取上传文件信息
            $file = $request->input('picname');
            /*print_r($file);*/
            $ext = $file->extension(); //获取文件的扩展名
            //随机一个新的文件名
            $filename = time().rand(1000,9999).".".$ext;
            //移动上传文件
            $file->move("./upload/",$filename);
                                
            return response($filename); //输出
            exit();
        }else{
            //闪存信息
            return redirect('demo/upload')->with('status', '请选择上传文件!');
        }
    }
error:Call to a member function isValid() on string
in FilmController.php (line 59)
at FilmController->doUpload(object(Request))
at call_user_func_array(array(object(FilmController), 'doUpload'), array(object(Request)))
in Controller.php (line 55)
ringa_lee
ringa_lee

ringa_lee

reply all(1)
phpcn_u1582

$request->input('picname')->isValid()
Call to a member function isValid() on string
The prompt is the error reported at this location! Print it yourself and tune it in!
Should: $request->file('picname')->isValid();

Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template