php - Laravel Call to a member function isValid() on null -
in project users can upload stuff , attach image. have controller isvalid check on file input. works great long select file. when don't select file error
call member function isvalid() on null
on line of code:
if (input::file('image')->isvalid())
the error obvious since don't select image have no idea how can fix this.
if can i'd happy :) in advance!
first need check if request containing file / input or not.
determining if file uploaded
if (request::hasfile('image')) { /*determining if uploaded file valid*/ if (request::file('image')->isvalid()) { // } }
just info make sure getting file while posting. enctype="multipart/form-data"
you can use of input , request facade. input class referencing \illuminate\http\request
in laravel
Comments
Post a Comment