php – Fehler beim Hochladen der Larvael5.4-Datei
ringa_lee
ringa_lee 2017-06-30 09:56:37
0
1
779

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

Antworte allen(1)
phpcn_u1582

$request->input('picname')->isValid()
Call to a member function isValid() on string
提示是这个位置报的错!自己打印 调调吧!
应该:$request->file('picname')->isValid();

Neueste Downloads
Mehr>
Web-Effekte
Quellcode der Website
Website-Materialien
Frontend-Vorlage