我创造了像在我看来图片上传空上Laravel 5.0
{!! Form::open(array('url' => 'user/posts', 'files'=> true)) !!}
<div class="form-group">
{!! Form::text('title',Input::old('title'),['class'=>'form-control', 'placeholder' => 'What is your title?']) !!}
</div>
<div class="form-group">
{!! Form::label('image', 'Your Image') !!}
{!! Form::file('image') !!}
<p class="help-block">Hey! Please don't upload over 15MB images!</p>
</div>
<div class="form-group">
{!! Form::label('caption', 'Don\'t miss to caption!') !!}
{!! Form::text('caption',Input::old('caption'),['class'=>'form-control', 'placeholder' => 'Your caption']) !!}
</div>
{!! Form::submit('Post now!',['class'=>'btn btn-info']) !!}
{!!Form::close() !!}
以下一种形式,我尝试DD()为我的形象从我的控制器,但它返回nulll。下面一个是我Controller
public function store(PostFormRequest $request)
{
dd($request->input('image'));
$post = new Post;
}
下一个是我PostFormRequest
<?php namespace App\Http\Requests;
use Response;
use Illuminate\Foundation\Http\FormRequest;
class PostFormRequest extends FormRequest {
public function rules()
{
return [
'title' => 'required',
'image' => 'mimes:jpeg,bmp,png'
];
}
public function authorize()
{
$image = $this->image;
if(empty($image))
return true;
else
return false;
}
public function forbiddenResponse()
{
return Response::make('Sorry!',403);
}
}
当我尝试dd($request->input('title'));
这是返回string(4) "test"
是我错了?