PHP generate file for download then redirect

前端 未结 11 2676
春和景丽
春和景丽 2020-11-22 09:08

I have a PHP app that creates a CSV file which is forced to download using headers. Here\'s the relevant part of the code:

header(\'Content-Type: applicatio         


        
11条回答
  •  无人及你
    2020-11-22 09:38

    Launch the PHP file which contains the CSV download using:

    Download CSV File
    

    or

    
    

    where the JavaScript function popoutWin is

    /*
     * Popout window that self closes for use with downloads
     */
    function popoutWin(link){
        var popwin = window.open(link);
        window.setTimeout(function(){
            popwin.close();
        }, 500);
    }
    

    This will open a window, to display the CSV download prompt and then immediately close the window, leaving only the prompt.

提交回复
热议问题