dongpu3792 2014-05-27 12:11
浏览 58
已采纳

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.

  • 写回答

3条回答 默认 最新

  • donglu2008 2014-05-28 10:08
    关注

    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.

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论
查看更多回答(2条)

报告相同问题?

悬赏问题

  • ¥20 求友友们解惑,感激不尽
  • ¥15 python中aiohttp.client_exceptions.ContentTypeError
  • ¥30 DeepLung肺结节检测生成最大froc值对应的epoch报错
  • ¥15 信号发生器如何将频率调大,步尽值改成10
  • ¥15 keil 5 编程智能家具,风扇台灯开关,人体感应等
  • ¥100 找一名渗透方面的专家
  • ¥20 使用Matlab APP设计一个插补小程序
  • ¥15 evo评估时曲线出现问题
  • ¥15 eNSP拓扑图配置实验
  • ¥20 有没有兄弟会替换fmod studio的.bank文件内的音效?