[eluser]Paul Skinner[/eluser]
I'm having a problem with the $this->upload->data() function.
I want to grab the file_name, image_width, and image_height data in the view and loop through to show all the images that have been uploaded.
At the moment it's uploading the images perfectly, I just can't get it to loop through and display the images in the 'image_success' view (the code is below).
I've got a feeling I'm using the foreach incorrectly in the view.
I've had a long day at work, and know I'm just being slow, so be patient with me :down:
Thanks for your help in advance.
Controller:
Code:
$config['upload_path'] = './site-images/';
$config['allowed_types'] = 'gif|jpg|png';
$field_name = "image";
$headData = array ( 'stylesheet' => array('/assets/css/coreStyle.css'),
//'conditionalcss' => array('/res/css/IE6style.css'),
//'conditionaljs' => array('/res/misc/iepngfix/iepngfix_tilebg.js'),
'title' => 'Upload an Image | Zoom2Room');
$this->load->library('upload', $config);
if ( ! $this->upload->do_upload($field_name))
{
$error = array('error' => $this->upload->display_errors());
$this->load->view('head', $headData);
$this->load->view('image_upload', $error);
}
else
{
$test = $this->upload->data();
$data = array('upload_data' => $this->upload->data());
$this->load->view('head', $headData);
$this->load->view('image_success', $data);
}
View:
Code:
<?php if(isset($upload_data)){ ?>
<?php foreach($upload_data as $item=>$value):?>
<img src="<?php echo $value['file_name'];?>" width="<?php echo $value['image_width'];?>" height="<?php echo $value['image_height'];?>" />
<?php endforeach; ?>