I have the following controller code, it should move all the five images to uploads
directory but it moves only one image.
Controller:
if(Input::hasFile('profile_pic')){
$pic = Input::file('profile_pic');
$mobile->photo1 = $pic[0]->getClientOriginalName();
$mobile->photo2 = $pic[1]->getClientOriginalName();
$mobile->photo3 = $pic[2]->getClientOriginalName();
$mobile->photo4 = $pic[3]->getClientOriginalName();
$mobile->photo5 = $pic[4]->getClientOriginalName();
foreach ($pic as $file){
if(!empty($file)){
$file->move(public_path() . '/uploads/', time() . '-' . 'laptop');
}
}
}
The images name are storing in database table fields successfully. But the not all images are moving to the destination folder only one image moves to the folder, Check foreach
loop.
via Chebli Mohamed
Aucun commentaire:
Enregistrer un commentaire