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

Popular posts from this blog

ios - RestKit 0.20 — CoreData: error: Failed to call designated initializer on NSManagedObject class (again) -

java - Digest auth with Spring Security using javaconfig -

laravel - PDOException in Connector.php line 55: SQLSTATE[HY000] [1045] Access denied for user 'root'@'localhost' (using password: YES) -