Level 41
When you open the form, are you setting the files option to true? Example:
Form::open(['url' => 'foo/bar', 'files' => true])
#project Problems
#1
I can’t upload an image
here is my html code :
<div class="form-group">
{!! Form::label('avatar','upload one image:') !!}
{!! Form::file('avatar',['class'=>'form-control']) !!}
@if($errors->has("avatar"))
<span class="help-block">{{ $errors->first("avatar") }}</span>
@endif
</div>
the controller method store : ... public function store(MemberRequest $request) { $avatar = $request->file("avatar”);
$name = time().$avatar->getClientOriginalName();
} ... when I submit the form i get this error
FatalErrorException in MemberController.php line 85:Call to a member function getClientOriginalName() on a non-object
I tried ... If($request->hasFile($avatar){
return “I have the file “; } else{ return “Error”; } ... when I submit the form the page displays the word Error
I tried ... var_dump($avatar); ... the page displays NULL
what’s wrong with my code?
When you open the form, are you setting the files option to true? Example:
Form::open(['url' => 'foo/bar', 'files' => true])
Please or to participate in this conversation.