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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 5, 20262026-06-05T14:21:23+00:00 2026-06-05T14:21:23+00:00

I am writing a simple file uploader in CodeIgniter 2.0.2. Pasting code below. Under

  • 0

I am writing a simple file uploader in CodeIgniter 2.0.2. Pasting code below.
Under certain conditions the browser hangs during this upload and I get “waiting for localhost” in the browser status bar (identical behavior in FF and Chrome).
I have verified that the file is being uploaded to the Windows temporary folder (the complete file), but the process gets stuck after that.
It appears that the condition for the bug is file size. But my php.ini has all the right settings for uploading files, and I still get the hang with a 700k file.
This bug occurs only when I run it on Windows 7 Apache, not on an Ubuntu box.
The suggested to me that some paths in the php.ini may be incorrectly set.
Apache log files have not been much help here because there is no error thrown.
I have tried using Chrome developer panel to debug but haven’t turned up anything useful.
I am currently trying to get XDebug working, but since no error is thrown and the process doesn’t complete, my expectations are low.
Any suggestions for how to trace this bug?
If there are specific php.ini settings you’d like to see, let me know, don’t want to do the big dump.

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);
    if ( ! $this->upload->do_upload()) // this is the native CI function, probably where the problem is. I can provide some of that code if anyone wants.
    {
        $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-05T14:21:24+00:00Added an answer on June 5, 2026 at 2:21 pm

    If your error only occurs on windows 7 apache, I think that your issue may be with the “is_dir()” “mkdir()” and “chmod()” commands — these terminal commands are linux specific and will not work so great on a windows system.

    I looked up the documentation on the mkdir() function in the PHP.net Manual at:

    http://us.php.net/manual/en/function.mkdir.php

    I found this in the comments section:

    kendsnyder at gmail dot com 04-May-2007 08:17
    When creating directories in Windows, trailing periods (“.”) are ignored. for example:

    <?php
    
    mkdir('c:/Buck Jr.',0755);    // on Windows creates "c:/Buck Jr"
    mkdir('c:/Elipses...',0755);  // on Windows creates "c:/Elipses"
    mkdir('c:/php.com',0755);     // on Windows creates "c:/php.com"
    
    ?>
    
    This is a Window's quirk, not a php shortcoming--meaning that you get the same results  from a Window's command prompt.
    

    So it seems it will work… but you are likely to have to futz with it to find the flavor that Windows systems prefer. Also it seems that you must specify the root drive on which to make the directory, e.g.: ‘c:\somedir’

    Also of interest, I did a quick google search and discovered that PHP has published a bug around the functionality you are using, specifically related to forward vs. back slashes of the windows vs. linux systems:

    https://bugs.php.net/bug.php?id=29797

    Here is a StackOverflow post related to your question:

    PHP mkdir(), chmod() and Windows

    So to summarize:

    • On a windows based web server, include the drive that the directory will be placed on

    • File Permissions on Windows are different from Linux (Windows doesn’t have a chmod or file permissions structure like Linux!) Although from what I can tell Windows is supposed give a folder the equivalent of a 777 permissions level — but this functionality seems buggy and error prone. But this also means that using the chmod() function on a windows system, you will get unpredictable results. For more info consult the PHP Manual: http://php.net/manual/en/function.chmod.php

    • Remember to use backslashes rather than forward slashes for the directory path, as Windows systems use back slashes, whereas Linux uses forward slashes.

    • When PHP creates a directory it uses the permissions that were granted to the user account that PHP is running under, which means that you may have to dig into windows to find what user permissions level your windows 7 Apache/PHP is running under and make that change there. I know, what a pain, right?

    • One final thing: mkdir() function returns true if the directory creation was successful and false if not — you may want to be testing for that condition before proceeding with the rest of your code, because if the directory doesn’t properly get created, all the rest of your code that relies on that directory existing is going to fail. Ultimately I think your browser is hanging upon submit because it is trying to access a function through PHP which there is no support for on Windows (chmod). Perform the function calls within a “Try/Catch” block to catch any exceptions that occur so that you can print them to screen or a log file if necessary:

      $proceed = false;
      try
      {
           // create directory
           if (! is_dir(BACKUP_DIR)) {
               $proceed = mkdir(BACKUP_DIR, 0777);
           }
           // or if it exists and has restricted file permissions, change them
           elseif(fileperms(BACKUP_DIR)!=0777){
               $proceed = chmod(BACKUP_DIR, 0777);
           }
      }
      catch(Exception $e)
      {
          echo $e->message;
      }
      
      if($proceed == TRUE)
      {
          /*Proceed with your code*/
      }
      else
      {
         /*Gracefully fail*/
      }
      

      Good luck man, this is why I prefer Linux Boxes for web servers!

      Cheers!

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

Sidebar

Related Questions

I am writing a simple batch file and i get this The syntax of
I'm writing a simple file uploader for a website. The user sees a form:
I am writing a simple file browser app with Nokia Qt4.7 on Symbian^3 platform.
I am writing some simple code to parse a file and return the number
Suppose I have a Runnable that does a simple file writing operation, and this
I am writing simple Linux module mod.c. When I compile mod.c file, it creates
I am writing a set of classes that handle simple file uploads with both
I am currently writing a simple C compiler, that takes a .c file as
I'm writing a small application in C that reads a simple text file and
I have the following simple methods for writing a python object to a 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.