我有一个按钮和onclick,它将调用一个ajax函数。
下面是我的ajax函数
function csv(){
ajaxRequest = ajax();//ajax() is function that has all the XML HTTP Requests
postdata = "data=" + document.getElementById("id").value;
ajaxRequest.onreadystatechange = function(){
var ajaxDisplay = docume
下面是我从浏览器创建和下载CSV文件的代码片段。
$input_array[] = ['注文日時', '受注番号',];
$input_array[] = ['2015-09-30', 'INV-00001',];
/** open raw memory as file, no need for temp files, be careful not to run out of memory thought */
$f = fopen('php://memory', 'w');
我正在尝试从php读取该文件,并单击一个按钮从用户界面下载该文件。
<?php
$file = 'download.csv'; //path to the file on disk
if (file_exists($file)) {
header('Content-Type: application/csv');
header('Content-Disposition: attachment; filename=contact-list.csv');
header('Pragma: no-cache