laravel adding .txt on the downloaded file

后端 未结 1 1982
Happy的楠姐
Happy的楠姐 2021-01-26 11:36

im trying to give the user ability to download a specific file. here is my code.

but it keeps adding .txt after the file is downloaded which I want is a .csv

<         


        
1条回答
  •  小蘑菇
    小蘑菇 (楼主)
    2021-01-26 12:13

    I'm pretty sure that your browser can't interpret the file. According to this solution, you need to force it to open 'save as...' dialog:

    $headers = array(
              'Content-Type: text/csv',
              'Content-disposition: attachment'
    );
    

    0 讨论(0)
提交回复
热议问题