samedi 13 octobre 2018

How to solve error "Call to a member function move() on string" in Laravel?

I am uploading image in the folder and saving data into the database. How to solve this error. The error is highlighting the line : $property_features_image->move($destinationPath,$property_features_image);

public function store(Request $request)
{
    $this->validate($request, [
                       'property_feature' => 'required|unique:property_features,property_features_name',
                       'property_icon' => 'required|image|mimes:jpg,png,jpeg|max:10240',

    ]);

    $property_features_name = $request->property_feature;
    $property_features_image = $request->file('property_icon');
    $property_features_image = $property_features_image->getClientOriginalExtension();
    $destinationPath = public_path('/images');
    $property_features_image->move($destinationPath, $property_features_image);

    DB::table('property_features')->insert([
    'property_features_name' => $property_features_name,
    'property_features_image' => $property_features_image,

    ]);

My Blade code:

 <form method="post" enctype="multipart/form-data" action="">
<div class="form-group">
<input type="hidden" value="" name="_token" />
<label for="Property">Add Property Feature</label>
<input type="text" class="form-control" id="property_feature" name="property_feature" placeholder="Enter Property Feature"> 
<label for="exampleFormControlFile1">Property Features's Icon</label>
<input type="file" class="form-control-file" id="property_icon" name="property_icon">


 <?php echo($errors->first('property_feature',"<li class='ab' style='color:red;'>:message</li>"));?>
 <?php echo($errors->first('property_icon',"<li class='ab' style='color:red;'>:message</li>"));?>

</div>



via Chebli Mohamed

Aucun commentaire:

Enregistrer un commentaire