0

I need to upload file using CI (version 3.0)
this is my view file
image_gallery.php

<?php 
  echo form_open_multipart('gallery_control');
  echo form_upload('userfile', 'upload_image');
  echo form_submit('submit', 'Upload');
  echo form_close();
?>  

this my controllers file
gallery_control.php

class Gallery_control extends CI_Controller 
{

  function index()
  {

    $this->load->model('gallery_model');

    if($this->input->post('upload'))
    {
        $this->gallery_model->do_upload();
    }
    else
    {
        //$this->gallery_model->display_errors();
    }
    //here I used template to call view file
    $data['main_content'] = 'image_gallery';
    $this->load->view('includes/template', $data);
  }
}   

this my models file
gallery_model.php

class Gallery_model extends CI_Model 
{
  var $gallery_path;

 public function __construct()
    {
        parent::__construct();

     //$this->load->helper(array('form', 'url')); #autoloaded from config file
       $this->gallery_path = realpath(APPPATH . '../uploaded_images');
    }


  public function do_upload()
  {
    $config = array(
            'allowed_types' => 'gif|png|jpeg',
            'upload_path' => $this->gallery_path,
            'max_size' => 2000
        );

    $this->load->library('upload', $config);

    $this->upload->do_upload();
  }
}  

this is my coding path after run this. I'm not getting image in uploaded_images folder which I created out site the application folder and there is no error showing it is returning to index page (image_gallery.php). whats wrong with my coding please help me?

Haither Ali
  • 183
  • 1
  • 10
  • Do you have permissions to write in that external folder? – Shomz Nov 25 '15 at 03:26
  • where I can check the permission and how do I check please? – Haither Ali Nov 25 '15 at 03:28
  • 1
    This one has some nice answers, but there might be even better ones: http://stackoverflow.com/questions/10990/what-are-the-proper-permissions-for-an-upload-folder-with-php-apache – Shomz Nov 25 '15 at 03:29
  • 1
    First I'd try to upload in the directory where your PHP file is, just for testing, and it that works, check the permission link above. – Shomz Nov 25 '15 at 03:30
  • from your link I could not get well explanation about my problem since i'm a new to this field If you can please help me. – Haither Ali Nov 25 '15 at 03:38
  • That (and similar) links will help you better than I can. Test if you can upload it to your project dir. – Shomz Nov 25 '15 at 03:40
  • CI3 requires First_capital file names of classes. Use it for controllers, models, libraries and hooks. – Tpojka Nov 25 '15 at 03:58

0 Answers0