CodeIgniter Forums
When I upload an image to my view page it comes up encypted - Printable Version

+- CodeIgniter Forums (https://forum.codeigniter.com)
+-- Forum: Archived Discussions (https://forum.codeigniter.com/forumdisplay.php?fid=20)
+--- Forum: Archived Development & Programming (https://forum.codeigniter.com/forumdisplay.php?fid=23)
+--- Thread: When I upload an image to my view page it comes up encypted (/showthread.php?tid=55842)



When I upload an image to my view page it comes up encypted - El Forum - 11-12-2012

[eluser]James_B[/eluser]
I know have my images storing into my desired folder, but how come whenever I upload an image to the screen it appears as a distorted image of sorts.

It appear as white container with a broken image symbol in the middle - why is this?

I have checked both my upload and base url paths:

this is my upload function in my controller
Code:
function upload()
  {
   $config['upload_path'] = './web-project-jb/assets/uploads/';//folder location of image
   $config['allowed_types'] = 'gif|jpg|png';
   $config['max_size'] = '10000';
   $config['max_width'] = '1024';
   $config['max_height'] = '768';
  
   $this->load->library('upload', $config);
   //fail show upload form
   if (! $this->upload->do_upload())
   {
  
    $error = array('error'=>$this->upload->display_errors());
  
  
    $username = $this->session->userdata('username');
    
    $viewData['username'] = $username;
    $viewData['profileText'] = $this->profiles->getProfileText($username);
    
    $this->load->view('shared/header');
    $this->load->view('homeprofile/homeprofiletitle', $viewData);
    $this->load->view('shared/nav');
    $this->load->view('homeprofile/upload_fail', $error);
    $this->load->view('homeprofile/homeprofileview', $viewData, array('error' => ' ' ));
    $this->load->view('shared/footer');
  
   }
  
   else
   {
    //successful upload so save to database
    
    
    $file_data = $this->upload->data();
    
    
    $data['img'] = base_url().'./web-project-jb/assets/uploads/'.$file_data['file_name'];// this is meant to display the image on-screen
  
    //$image = chunk_split( base64_encode( file_get_contents( $data['file_name'] ) ) );
    

    $username = $this->session->userdata('username');
    
    
    $viewData['username'] = $username;
    $viewData['profileText'] = $this->profiles->getProfileText($username);
    
    $username = $this->session->userdata('username');
    
    $this->load->view('shared/header');
    $this->load->view('homeprofile/homeprofiletitle', $viewData);
    $this->load->view('shared/nav');
    $this->load->view('homeprofile/upload_success', $data);
    $this->load->view('homeprofile/homeprofileview', $viewData, array('error' => ' ' ));
    $this->load->view('shared/footer');
   }
  
  }