mercredi 3 octobre 2018

I seems cant to save my Uploaded file to database LARAVEL?

hello im trying to save my filename in database laravel , but it gives me

Creating default object from empty value

what happens ?

    Controller

    public function insertproof(Request $request)
        $id = $request['id'];
    if ($request->hasFile('rent_proof')){
        $filepath = $request->file('rent_proof')->store('app/folder_proof');
    $result = rent::find($id);
    $result->rent_proof=$filepath;
    $result->save();
    }

and here is my view and this view is from mymodal

    <form method="POST" action="" enctype="multipart/form-data">
        
            <div class="form-group">
            <input type="file" class="form-control" name="rent_proof"  id="proof">
            </div>
        <button type="submit" class="btn btn-success">Save</button>
    </form>

This is my model

   RentModel.php

   protected $primaryKey = 'id';
   protected $fillable = ['rent_proof'];

thanks for the care is there anything that i miss?

Version laravel 5.5 PHP 7.2

Before this i can succesfully save image to my folder but i still not touch the database. then i make the function above to save image to my folder and mark it to database. but it gives me these error



via Chebli Mohamed

Aucun commentaire:

Enregistrer un commentaire