Thursday 08 September 2011 4:28:19 am
There are several ways you can do this within a module view php file, I will show two samples.
Use eZFile class:
.. // $result is the file content $file = new eZFile(); unlink('file.txt'); $file->create( 'file.txt', false, utf8_decode( $result )); $file->download( 'file.txt',true, false ); eZExecution::cleanExit();
Use PHP header function:
... // sample from eZSurvey - $output is the file content $contentLength = strlen( $output ); header( "Pragma: " ); header( "Cache-Control: " ); header( "Content-Length: $contentLength" ); // header( "Content-Type: application/vnd.ms-excel" ); header( "Content-Type: text/comma-separated-values" ); header( "X-Powered-By: eZ Publish" ); header( "Content-disposition: attachment; filename=export.csv" ); // header( "Content-Transfer-Encoding: binary" ); ob_end_clean(); print( $output ); // fflush(); eZExecution::cleanExit(); ...