You are not logged in.
Pages: 1
Hello,
I'm writing a simple glpi plugin and I try to send the data as file through the browser....
ob_start();
header('Content-Type: text/csv; charset=utf-8');
header('Content-Disposition: attachment; filename=csv_export.csv');
$header_args = array( 'ID', 'Name', 'Email' );
$data = array(
array('1', 'Test 1', 'test1@test.com'),
array('2', 'Test 2', 'test2@test.com'),
array('3', 'Test 3', 'test3@test.com'),
);
ob_end_clean();
$output = fopen( 'php://output', 'w' );
fputcsv( $output, $header_args );
foreach( $data as $data_item ){
fputcsv( $output, $data_item );
}
fclose( $output );
exit;
isn't working at all, the only thing I have is the content of data on the page.
Someone can help me?
Regards,
Offline
Why are you buffering the output, which in this case contains only your headers, and then disregarding it?
GLPI Collaborator and Plugin Developer.
My non-English comments are automated translations. Sorry for any confusion that causes.
Mes commentaires non anglais sont des traductions automatiques. Désolé pour toute confusion qui cause.
Mis comentarios que no están en inglés son traducciones automáticas. Perdón por cualquier confusión que cause.
Offline
Pages: 1