Welcome Guest, Not a member yet? Register   Sign In
$_FILES Array getting empty when using $this->form_validation->run()
#22

(This post was last modified: 06-12-2019, 04:07 AM by hc-innov.)

step by step...
Change your model and return the last_inserted_id.
In your controller, change this part of code to:

PHP Code:
if($this->form_validation->run())
 
          {
 
              $prop_title ucwords(strtolower($this->security->xss_clean($this->input->post('prop_title'))));
 
              $prop_status ucwords(strtolower($this->security->xss_clean($this->input->post('prop_status'))));
 
              $prop_type ucwords(strtolower($this->security->xss_clean($this->input->post('prop_type'))));
 
              $prop_price $this->security->xss_clean($this->input->post('prop_price'));
 
              $prop_sqft $this->security->xss_clean($this->input->post('prop_sqft'));
 
              $prop_rooms $this->security->xss_clean($this->input->post('prop_rooms'));
 
              $prop_address $this->security->xss_clean($this->input->post('prop_address'));
 
              $prop_owner_name $this->security->xss_clean($this->input->post('prop_owner_name'));
 
              $prop_owner_email $this->security->xss_clean($this->input->post('prop_owner_email'));
 
              $prop_owner_phone $this->security->xss_clean($this->input->post('prop_owner_phone'));
 
              $prop_detailed_info $this->security->xss_clean($this->input->post('prop_detailed_info'));
 
              $prop_current_status $this->security->xss_clean($this->input->post('prop_current_status'));
 
               $propertyInfo = array('title'=>$prop_title'status'=>$prop_status'type'=>$prop_type'price'=>$prop_price,
 
                                     'sqft'=>$prop_sqft'rooms'=>$prop_rooms'address'=>$prop_address'name'=>$prop_owner_name,
 
                                     'email'=>$prop_owner_email'phone'=>$prop_owner_phone'detailedInfo'=>$prop_detailed_info,
 
                                     'currentStatus'=>$prop_current_status);
 
              $result $this->property_model->addNewProperty($propertyInfo);
echo 
$result.'<br>';
 
              if (!empty($_FILES)) {
 
                  $count_img count($_FILES['file']['name']);
 
                  foreach($_FILES['file']['tmp_name'] as $key => $value) {

 
                   $tempFile $_FILES['file']['tmp_name'][$key];
 
                   $fileName $_FILES['file']['name'][$key];
 
                   $targetPath 'property-images/';
 
                   $targetFile $targetPath $fileName ;

 
                   //$this->load->model('user_model');

 
                   $imgData = array('path'=>$targetFile,'propertyid'=>$result);

 
                   if(move_uploaded_file($tempFile$targetFile))
 
                   {
 
                       echo 'Move upload file and add propertyImgs<br>';
 
                       $this->property_model->addPropertyImgs($imgData);
 
                   }
 
                  }
 
              } else {
 
                  echo '$_FILES is empty';
 
              }
die();
 
            
and post the result
Reply


Messages In This Thread
RE: $_FILES Array getting empty when using $this-&gt;form_validation-&gt;run() - by hc-innov - 06-12-2019, 04:06 AM



Theme © iAndrew 2016 - Forum software by © MyBB