I have upload controller to upload images. file_view is the html file where I used to upload my image and upload_success is the file where I used to retrieve file. In the upload_success file output appears like this
file_name: images.jpg file_type: image/jpeg file_path: C:/xampp/htdocs/Test/uploads/ full_path: C:/xampp/htdocs/Test/uploads/images.jpg raw_name: images orig_name: images.jpg client_name: images.jpg file_ext: .jpg file_size: 10.65 is_image: 1 image_width: 218 image_height: 232 image_type: jpeg image_size_str: width="218" height="232" Can someone help me to view the image using tag?
Controller
<?php if (!defined('BASEPATH')) exit('No direct script access allowed'); class Upload_Controller extends CI_Controller { public function __construct() { parent::__construct(); } public function index(){ $this->load->view('file_view', array( 'error' => ' ' )); } public function file_view() { $this->load->view('file_view', array( 'error' => ' ' )); } public function do_upload() { $config = array( 'upload_path' => "./uploads/", 'allowed_types' => "gif|jpg|png|jpeg|pdf", 'overwrite' => TRUE, 'max_size' => "2048000", // Can be set to particular file size , here it is 2 MB(2048 Kb) 'max_height' => "768", 'max_width' => "1024" ); $this->load->library('upload', $config); if ($this->upload->do_upload()) { $data = array( 'upload_data' => $this->upload->data() ); $this->load->view('upload_success', $data); } else { $error = array( 'error' => $this->upload->display_errors() ); $this->load->view('file_view', $error); } } } ?> File_view
<?php echo $error;?> <!-- Error Message will show up here --> <?php echo form_open_multipart( 'upload_controller/do_upload');?> <?php echo "<input type='file' name='userfile' size='20' />"; ?> <?php echo "<input type='submit' name='submit' value='upload' /> ";?> <?php echo "</form>"?> upload_success
<h3>Your file was successfully uploaded!</h3> <!-- Uploaded file specification will show up here --> <ul> <?php foreach ($upload_data as $item => $value):?> <li> <?php echo $item;?>: <?php echo $value;?> </li> <?php endforeach; ?> </ul> <p> <?php echo anchor('upload_controller/file_view', 'Upload Another File!'); ?> </p>