dimanche 19 février 2017

I want to update the image column only if user select the new picture using laravel

Store function for image ProductController.php

 public function store_image(Request $request, $id)
{

    $image = Product::find($id);
    $imageupdate = $request->all();

    for ($i = 1; $i < 6; $i++) {
        $n = 'photo_' . $i;
        if ($file = $request->file($n))
        {
            $name = time() . $file->getClientOriginalName();
            $file->move('img/products', $name);
            //two parameter of move function are 1. name of directory and 2.name of the file to store
            $imageupdate['photo_' . $i] = $name;
        }
    }

Table for Product

Table for Product



from Newest questions tagged laravel-5 - Stack Overflow http://ift.tt/2l9nQeo
via IFTTT

Aucun commentaire:

Enregistrer un commentaire