Sending a multipart response to download in Zend Framework

I post files in the upload actions helper (if needed):

...
$response->sendHeaders();

$chunksize = 1 * (1024 * 1024);
$bytesSent = 0;

if ($httpRange) {
    fseek($file, $range);
}

while(!feof($file) &&
   (!connection_aborted() &&
   ($bytesSent < $newLength))
) {
    $buffer = fread($file, $chunksize);
//      $response->appendBody($buffer); // this would be better
    print($buffer);
    flush();
    $bytesSent += strlen($buffer);
}
fclose($file);

      

I suspect the best way would be to use an object $response

instead print

.

What is the recommended way to send large response objects using Zend Framework?

+2


a source to share


1 answer


I usually use Noginn Action Helper to send the file for upload. Here's a good description in another answer: How to add a third party action helper to a Zend Framework 1.8+ application?



URL for SendFile.php: https://github.com/noginn/noginn/blob/master/Noginn/Controller/Action/Helper/SendFile.php

0


a source







All Articles