Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 897115
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 15, 20262026-05-15T14:50:08+00:00 2026-05-15T14:50:08+00:00

I am using Codeigniter and I am trying to upload multiple files into a

  • 0

I am using Codeigniter and I am trying to upload multiple files into a database.
The files are seperate fields not multiple files for one field.

I followed this post –http://codeigniter.com/forums/viewthread/110130/P0/

I almost have it working but I am having some trouble with adding the uploaded data into my db.

Here is my Controller function…

function addStation(){
        // set common properties
        $data['title'] = 'Add new station';
        $data['action'] = site_url('admin/station/addStation');
        $data['link_back'] = anchor('admin/station/index/','Back to list of stations',array('class'=>'back'));

        // set validation properties
        $this->_set_fields();
        $this->_set_rules();

        $config['allowed_types'] = 'pdf|xls|doc|docx';
    $config['max_size'] = '1000';
    $config['max_width']  = '1024';
    $config['max_height']  = '768';
    $path_to_uploads='./uploads/files/stations';
    $config['upload_path'] = $path_to_uploads;

    // File specific (overrule global and optional)
$config['logo_file']['upload_path']   = './uploads/images/stations';
$config['logo_file']['allowed_types'] = 'gif|jpg|png';


    $this->load->library('upload', $config);
    //add this
    $this->upload->initialize($config);
if (!$this->upload->do_upload(array('rajar_file','playlist_file','map_file', 'logo_file'))){
        $error = $this->upload->display_errors();
        echo "<script>alert($error);</script>";
    }else{
        $data = array('upload_data' => $this->upload->data(array('rajar_file','playlist_file','map_file', 'logo_file')));

        $rajar_file_name = $upload_data['rajar_file']['file_name'];
        $rajar_full_file_path = $path_to_uploads.'/'.$rajar_file_name;

         $playlist_file_name = $upload_data['playlist_file']['file_name'];
        $playlist_full_file_path = $path_to_uploads.'/'.$playlist_file_name;

         $map_file_name = $upload_data['map_file']['file_name'];
        $map_full_file_path = $path_to_uploads.'/'.$map_file_name;

         $logo_file_name = $upload_data['logo_file']['file_name'];
        $logo_full_file_path = $path_to_uploads.'/'.$logo_file_name;
    }

// run validation
        if ($this->validation->run() == FALSE){
            $data['message'] = '';
        }else{
            // save data
            $station = array('name' => $this->input->post('name'),
                            'rajar' => $rajar_full_file_path,
                            'playlist' => $playlist_full_file_path,
                            'map' => $map_full_file_path,
                            'logo' => $logo_full_file_path    );
            $id = $this->stationModel->save($station);

            // set form input name="id"
            $this->validation->id = $id;

            // set user message
            $data['message'] = '<div class="success">add new station success</div>';
        }

          $this->template->set('title', 'Admin - Add New Station!');
      $this->template->load('admin/template', 'admin/stationEdit', $data);


    }

After the form is submitted I get the following errors…

Message: Undefined variable: rajar_full_file_path

Message: Undefined variable: playlist_full_file_path

Message: Undefined variable: map_full_file_path

Message: Undefined variable: logo_full_file_path

Am I being daft, I can’t figure it out?

Thanks
Dan

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-15T14:50:09+00:00Added an answer on May 15, 2026 at 2:50 pm

    Seems that your code is entering the first if statement, then passing the form validation (thus never defining your variables) and then trying to use those variables in the second else code block.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am trying to delete multiple record(s) by using codeigniter $this->db->delete() and $this->db->where() I
I am using CodeIgniter to upload some files through a form. I know how
I am trying to upload two files at once (two file fields) with codeigniters
I'm using Codeigniter..and I'm new to this. What I'm trying to do is to
Been playing with this for too long now! I'm using codeigniter. I am trying
I am using Codeigniter with the TankAuth library installed and trying to upload to
I have a form and I am trying to submit data into database using
I am using codeigniter and jQuery form plugin. I am trying to upload a
I'm using codeIgniter and I'm getting internal server error when trying to upload large
Trying to make a place for people to upload files to this site. I

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.