parsecsv / parsecsv-for-php

CSV data parser for PHP.
MIT License
681 stars 176 forks source link

output with null filename still prompting to download file #194

Closed charperimg closed 3 years ago

charperimg commented 4 years ago

Calling $csv->output(NULL, $csv_data, $csv_columns) still prompts to download the file.

Issue is in /Src/Csv.php, line 445 for public function output

    if (empty($filename)) {

The above needed to be changed to

    if (empty($filename) && !is_null($filename)) {

Which ensures the function does not set a filename if the filename has been set to null so as to not prompt the download.

Hope this helps. We are running php 7.4.8.

gogowitsch commented 3 years ago

Thanks for opening an issue here. I think calling $csv->unparse($csv_data, $csv_columns) directly is the better option for you.

If you decide against $csv->unparse(): I believe that adding the is_null() check might break some existing library users' code. Please set $csv->output_filename = NULL; instead. Do this before calling $csv->output().