2014-05-27 12:11

WAMP或Codeigniter严重上传错误 - 无法上传文件


I am getting mad trying to achieve something that is supposed to be very simple. First of all, I have the following upload form that works flawlessly under OS X + XAMPP. When moving this script to WAMP + Windows Server, I get serious problems during the file upload. I am using Codeigniter.

public function importExcel () {        
    $config['upload_path'] = 'upload/';
    $config['allowed_types'] = 'xls';
    $config['max_size'] = '0';
    $config['overwrite'] = FALSE;
    $this->load->library('upload', $config);

    if (!($this->upload->do_upload())) {
        echo $this->upload->display_errors();

    $upload_data = $this->upload->data(); 
    $data['filename'] = $upload_data['file_name'];

This is my simple function. The upload folder is located under www/mywebsite/. Codeigniter's config.php file is configured correctly.

When I try to upload a xls file, the server crashes (interrupting its connection). Meaning that I get this page with error: ERR_CONNECTION_RESET, instead of showing me the upload errors.

Here is what I can say:

  • The file is not uploaded and I cannot find it in the upload folder.
  • The file upload actually starts, I see in the bar below the browser window that it is loading the file. When it comes to 100% percentage, I get the page linked above.

Here is what I have tried:

  • Changing the upload folder to /upload/, ./upload/ and stuff. When I tried to do ../upload/, i get the error and the page doesn't crash. It says he cannot find the right folder. This means that the folder is found during the upload and the problem is somewhere else.
  • Adding the xls MIME type to .htaccess.

Here is my actual .htaccess file in case it could be necessary.

RewriteEngine on
RewriteCond $1 !^(index\.php|resources|robots\.txt)
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ index.php/$1 [L,QSA]
RewriteBase /websitefolder/

I repeat that this same code works good under OS X + XAMPP with the same directory structure.

EDIT: forgot to say I tried to upload xls of any kind and any size, even very little. This has nothing to do with upload limit probably, I already raised up the variables.

EDIT 2: my PHP error log is totally empty. These are the rows that get added to my Apace error log when I try the upload.

[Tue May 27 14:22:54 2014] [notice] Parent: child process exited with status 255 -- Restarting.
[Tue May 27 14:22:56 2014] [notice] Apache/2.2.21 (Win64) mod_ssl/2.2.21 OpenSSL/1.0.0d PHP/5.3.8 configured -- resuming normal operations
[Tue May 27 14:22:56 2014] [notice] Server built: Sep 24 2011 19:57:51
[Tue May 27 14:22:56 2014] [notice] Parent: Created child process 4736
[Tue May 27 14:22:56 2014] [warn] Init: Session Cache is not configured [hint: SSLSessionCache]
[Tue May 27 14:22:56 2014] [notice] Child 4736: Child process is running
[Tue May 27 14:22:56 2014] [notice] Child 4736: Acquired the start mutex.
[Tue May 27 14:22:56 2014] [notice] Child 4736: Starting 64 worker threads.
[Tue May 27 14:22:56 2014] [notice] Child 4736: Starting thread to listen on port 80.
[Tue May 27 14:22:56 2014] [notice] Child 4736: Starting thread to listen on port 80.

EDIT 3: tested a non-with-Codeigniter file upload by using w3schools sample code. I get:

Upload: test.php
Type: application/octet-stream
Size: 26.90234375 kB
Stored in: C:\Wamp\tmp\phpAAB5.tmp

But when I go in C:\Wamp\tmp I cannot see the file. There are other temporary files of the same kind however. By using the code under Saving the Uploaded File the upload works correctly and I CAN find the file I uploaded.

I am desperate because I need this for a client. Any help? Thank you.

  • 点赞
  • 写回答
  • 关注问题
  • 收藏
  • 复制链接分享
  • 邀请回答


  • donglu2008 donglu2008 7年前

    The problem has probably something to do with CodeIgniter libraries. Using the same code provided by the official documentation I am still NOT able to upload xls documents but I was able to achieve this by using the corresponding, standard PHP upload form.

    Codeigniter is not able to upload the file and while performing this check:

    if (!($this->upload->do_upload())) {
       echo $this->upload->display_errors();

    The web application crashes instead of returning the error. If I disable this check, I get no errors but clearly the file is not uploaded.

    I will report this Stackoverflow discussion to the Codeigniter community and see if they can confirm what I just wrote.

    点赞 评论 复制链接分享
  • dpblwmh5218 dpblwmh5218 7年前


    RewriteBase /

    if its hosted on root other wise add directory name like

    RewriteBase /testfolder/

    点赞 评论 复制链接分享
  • dougu3988 dougu3988 7年前
    $config['upload_path'] = FCPATH . 'upload/';

    path need to be set to abolute path.

    RewriteEngine on
    RewriteBase /websitefolder/
    RewriteCond $1 !^(index\.php|resources|robots\.txt)
    RewriteCond %{REQUEST_FILENAME} !-f
    RewriteCond %{REQUEST_FILENAME} !-d
    RewriteRule ^(.*)$ index.php/$1 [L,QSA]

    This is how should look your .htaccess

    and dont forget to remove index.php in config.php

    $config['base_url'] = '';
    点赞 评论 复制链接分享