I want to upload multiple image files in database .. Here is the view part :
<input type="file" name="photo[]" >
<input type="file" name="photo[]" >
<input type="file" name="photo[]" >
And I want to store the path into different field in database..
controller code:
$files = Input::file('photo');
$names = [];
foreach ($files as $file) {
$names[] = $file->getClientOriginalName();
}
$imageName1 = time().'.'.$names[0];
$imageName2 = time().'.'.$names[1];
$imageName3 = time().'.'.$names[2];
$product->primary_image = $imageName1;
$file->move('images/', $imageName1);
$product->optional_image_one = $imageName2;
$file->move('images/', $imageName2);
$product->optional_image_two = $imageName3;
$file->move('images/', $imageName3);
I got the following Error:
Creating default object from empty value in
$product->primary_image = $imageName1;
Can anyone what's the error for assigning into object? or solution please ..
from Newest questions tagged laravel-5 - Stack Overflow http://ift.tt/2iFqEzd
via IFTTT
Aucun commentaire:
Enregistrer un commentaire