$file = Request::file('photo');//文件 $name = input::get('name');//其他属性值 $allowed_extensions = ["png", "jpg", "gif"]; if ($file->getClientOriginalExtension() && !in_array($file->getClientOriginalExtension(), $allowed_extensions)) { return ['error' => 'You may only upload png, jpg or gif.']; } $destinationPath = 'storage/uploads/'; //public 文件夹下面建 storage/uploads 文件夹 $extension = $file->getClientOriginalExtension(); $fileName = str_random(10).'.'.$extension; $file->move($destinationPath, $fileName); $filePath = asset($destinationPath.$fileName); $info=DB::insert('insert into photo(pname,photo) VALUES (?,?)',[$name,$filePath]);//入库 if($info){ return Redirect('/show'); }else{ echo "no"; }