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 7914783
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 3, 20262026-06-03T14:13:57+00:00 2026-06-03T14:13:57+00:00

I am trying to upload a single file in CodeIgniter 2.0.2 in a normal

  • 0

I am trying to upload a single file in CodeIgniter 2.0.2 in a normal way.
The do_upload() function returns true but no file appears in the directory.
Directory permissions appear to be fine (after running other diagnostics not shown in code below), so it makes no sense that the file is not appearing in the upload directory.
Here is controller and view code, adapted straight from the CI docs.

Controller:

function do_upload_sql(){
    // create directory
    if (! is_dir(BACKUP_DIR)) {
        mkdir(BACKUP_DIR, 0777);
    }
    // or if it exists and has restricted file permissions, change them
    elseif(fileperms(BACKUP_DIR)!=0777){
        chmod(BACKUP_DIR, 0777);
    }

    $config['upload_path'] = BACKUP_DIR;
    $config['allowed_types'] = 'backup'; // an SQL backup file type
    $config['overwrite'] = TRUE;
    $this->load->library('upload', $config);
    //$this->upload->initialize($config);  //redundant, so commenting out
    if ( ! $this->upload->do_upload())
    {
        $data['action'] = 'c_backup_restore/do_upload_sql';
        $tab_error = array('error' => $this->upload->display_errors());
        $data['error'] = $tab_error['error'];
        $this->load->view('common/header');
        $this->load->view('v_upload_sql', $data);
    }
    else
    {
        echo "success"; // yes it's getting here, but i get no file!
        $data = array('upload_data' => $this->upload->data());
        $file_upload = $data["upload_data"];
        $this->restore_backup($file_upload); // go do something useful with the file
    }
}

View:

<p>Select the backup file</p>
<div class="not_success"><?php echo $error;?></div>
<?php echo form_open_multipart($action);?>
<input type="file" name="userfile" size="30" />
<input type="submit" value="Upload" />
</form>
  • 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-06-03T14:13:59+00:00Added an answer on June 3, 2026 at 2:13 pm

    I found the bug using the xDebug profiler.
    It turned out that the native php function chdir(path) further downstream was the problem.
    @qwertzman’s link to paths in CI may prove to be helpful to determining exactly why the hangup occurs.

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

Sidebar

Related Questions

I am trying to upload a single .csv file in ASP.NET MVC. In my
trying to upload a file on a facelets page using Tomahawk2.0 1.1.11. But I
I'm trying to upload a file with Apache's HTTP Client and MultipartRequests, but it
Iam trying to upload the video but when file uploads the following response displays
I'm trying to upload my android app, but instead of my app name Соновник
I am trying to upload Excel only file in Struts2 WEB Application. So using
I am trying to upload a .csv file and than save each row to
I'm trying to upload files with Ajax (Valums Ajax File Upload) in ASP.NET MVC3,
I was trying to upload a csv file to update a table in my
I trying to upload a newsstand application for ipad. I have a icon file

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.