Wordpress将CSV导出到本地/ wp-content / uploads

时间:2018-06-22 09:06:59

标签: php wordpress

我想将csv文件放在/ wp-content / uploads下,而不是下载它。以下php代码下载此csv文件

我正在使用此php代码

header('Content-Type: text/csv');
header('Content-Disposition: attachment; filename=data.csv');
$stream = fopen('php://output', 'w+');
fputcsv($stream, $csv_header);
foreach($arrCSV as $key => $assoc_row){
    $numeric_row = array();
    foreach ($csv_header as $header_name) {
        mb_convert_variables('UTF-8', $assoc_row[$header_name]);
        $numeric_row[] = $assoc_row[$header_name];
    }
    fputcsv($stream, $numeric_row);

0 个答案:

没有答案