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条)

报告相同问题?

悬赏问题

  • ¥50 导入文件到网吧的电脑并且在重启之后不会被恢复
  • ¥15 (希望可以解决问题)ma和mb文件无法正常打开,打开后是空白,但是有正常内存占用,但可以在打开Maya应用程序后打开场景ma和mb格式。
  • ¥20 ML307A在使用AT命令连接EMQX平台的MQTT时被拒绝
  • ¥20 腾讯企业邮箱邮件可以恢复么
  • ¥15 有人知道怎么将自己的迁移策略布到edgecloudsim上使用吗?
  • ¥15 错误 LNK2001 无法解析的外部符号
  • ¥50 安装pyaudiokits失败
  • ¥15 计组这些题应该咋做呀
  • ¥60 更换迈创SOL6M4AE卡的时候,驱动要重新装才能使用,怎么解决?
  • ¥15 让node服务器有自动加载文件的功能