Pregunta

I've got a site built in Kohana and I'm trying to allow an Excel file upload. I'm using PHPExcel to read the data. It works fine on my local server but it's failing on the remote server. (The remote server is hosted at xmission.com)

So the code in the controller is as follows:

public function action_bulk_upload()
{
    if ($path = Kohana::find_file('vendor', 'PHPExcel')) {
        require_once $path;
    } 

    $objPHPExcel = PHPExcel_IOFactory::load($_FILES['upload']['tmp_name']);              
    $worksheet   = $objPHPExcel->getActiveSheet();

    $range = range('A', 'Z');
    $data  = array();
    $i     = 1;

    while ($worksheet->cellExists('A' . $i)) {
        $row = array();

        foreach ($range as $letter) {
            if (!$worksheet->cellExists($letter . $i)) {
                break;
            }

            $cell = $worksheet->getCell($letter . $i);    
            $row[] = $cell->getValue();
        }

        $data[] = $row;
        $i++;
    }

    $worksheet = null;
    $objPHPExcel->disconnectWorksheets();
    $objPHPExcel = null;

    $view = View::factory('content/admin/events/bulk_form')
        ->bind('data', $data);
    $this->add_content($view);

    // The code gets here
}

The code makes it all the way through the controller but unfortunately I get a 500 Internal Server Error. The error log says:

[Wed Jun 26 12:45:08 2013] [warn] (104)Connection reset by peer: mod_fcgid: read data from fastcgi server error.
[Wed Jun 26 12:45:08 2013] [warn] (104)Connection reset by peer: mod_fcgid: ap_pass_brigade failed in handle_request function

It sounds me to like I need to change the FastCgi settings but it's a shared hosting account so I might not be able to. Thanks for the help!

¿Fue útil?

Solución

By default FastCGI processes exit after 500 requests. You can either raise PHP_FCGI_MAX_REQUESTS (in the wrapper) or limit FcgidMaxRequestsPerProcess to 500 in block.

I don't think you can resolve this without modifying FastCGI configuration, but I could be wrong though.

Read http://httpd.apache.org/mod_fcgid/mod/mod_fcgid.html#examples

Otros consejos

I'd say either your file is too big or your script exceeds max. execution time. Try this code before calling your function:

ini_set('max_execution_time', 0); // No time limit
ini_set('post_max_size', 20M);
ini_set('upload_max_filesize', 20M);
Licenciado bajo: CC-BY-SA con atribución
No afiliado a StackOverflow
scroll top