Welcome Guest, Not a member yet? Register   Sign In
set default value in array if empty when uploading image
#1

[eluser]livewirerules[/eluser]
below is my code to upload multiple images and it works fine. The problem that im having is if a user doesn't select an image/images to upload or uploads less than 5 images how can i set a default value in the array

eg: if img3,img4,img5 is not selected set the values a default.jpg

can some one please suggest how to do that?
Code:
for($i = 1; $i < 6; $i++) {
        
        $upload = $this->upload->do_upload('image'.$i);
      
       $q= $this->upload->data();
      
       $x['image'.$i]= $q['file_name'];
  
  $data =array(
  'img1'=>$x['image1'],
  'img2'=>$x['image2'],
  'img3'=>$x['image3'],
  'ime4'=>$x['image4'],
  'img5'=>$x['image5']  
  );
  var_dump($data);
}

any help will be appreciated




Theme © iAndrew 2016 - Forum software by © MyBB