2
public function index(){
    $image = null;//tem var
    $config['upload_path'] = './assets/uploads/';
    $config['allowed_types'] = 'gif|jpg|jpeg|jpe|png';
    $config['max_size']      = '4000000';

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

    $this->form_validation->set_rules('title', 'Album Title', 'required');

    if($this->form_validation->run() == FALSE){
        $data['imagePath'] = base_url().'assets/uploads/';
        $data['album'] = $this->gallery->getAlbum();
        $this->load->view('admin/album', $data);
    }else{
        if (! $this->upload->do_upload('image')){//file upload
            $this->image = null;
        }else{
            $tem = array('upload_data' => $this->upload->data());
            $this->image = $tem["upload_data"]["file_name"];
        }//end else

         $data=array(
            'title' => $this->input->post('title'),
            'featured' => $this->image,
            'created_on' =>  date("Y-m-d")
         );

         if($this->gallery->createAlbum($data)){
            $this->session->set_flashdata('created','Album Has Been Created');
            redirect("admin");
         }
    }   
}

public function viewGallery($album_id){
    $config['upload_path']          = FCPATH.'assets/uploads/';
    $config['allowed_types']        = 'gif|jpg|jpeg|jpe|png';
    $config['max_size']             = 10000;
    $this->load->library('upload', $config);

    $data['imagePath'] = base_url().'assets/uploads/';
    $data['images'] = $this->gallery->getGalleryWithId($album_id);
    $data['album_id'] = $album_id;
    $this->load->view('addGallery', $data);
}

Uploads to the database but not the folder specified... Don't know what to do next.. Any help will really be good. I don't know where to put the path foldername wherein the file should be uploaded. The only thing that is uploading to the database works.

Thanks in advance

1

2 Answers 2

1

Try to add FCPATH

$config['upload_path'] = FCPATH.'/assets/uploads/';
Sign up to request clarification or add additional context in comments.

3 Comments

i dont knw if it has something to do with permissions
but wen i integerate it.... upload to database works but not file upload
I tried using FCPATH./assets/uploads/'; But that won't work because FCPATH has a trailing / after it. Which makes the path incorrect. It needs to be FCPATH.'assets/uploads/';
0

Try this one. First Define any folder name in which you want to insert the file. Like in this case i have made 'title' the folder name at my end.

if($this->form_validation->run())     
        {  
            $title=$this->input->post('title');

            $config['upload_path']          = './assets/courses/'.$title;
            $config['allowed_types']        = 'gif|jpg|png|jpeg';
            $config['max_size']             = 1000;
            $config['max_width']            = 500;
            $config['max_height']           = 300;
            $this->load->library('upload', $config);
            if (!is_dir('./assets/courses/'.$title)) {
             mkdir('./assets/courses/'.$title, 0777, TRUE);
         }

Hope So this will help You.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.