控制器代码 -
case 'update_dimg':
/* for updating User Profile image */
$dUId = isset($_REQUEST['udid']) ? $_REQUEST['udid'] : '';
$bUrl = isset($_REQUEST['bUrl']) ? $_REQUEST['bUrl'] : '';
$ddetails = $this->profile->getDriverDetails($dUId);
$imgPath = isset($_FILES['uDImg']['name']) ? $_FILES['uDImg']['name'] : '';
$this->load->helper('image');
if (!empty($imgPath)) {
$imageData = do_upload('uDImg', 'jpg|jpeg|gif|png', 'driver');
if (!empty($ddetails->image_path) && !empty($imageData['file_name'])) {
@unlink('uploads/' . $ddetails->image_path);
@unlink('uploads/thumbs/' . $ddetails->image_path);
}
$imgPath = $imageData['file_name'];
}
$this->data = array('image_path' => $imgPath);
$a = $this->update->driver_basic_info($this->data, $dUId);
if($imageData['error']){
$this->session->set_flashdata('set_msg', $imageData['errorMsg']);
$this->session->keep_flashdata('set_msg');
}
redirect('profile');
die();
break;
查看代码 -
<div>
<?php
print_r($this->session->all_userdata());
if($this->session->flashdata('set_msg')){
echo $this->session->flashdata('set_msg');
}else{
echo "else condition";
}
?>
</div>