从php页面下载的文件中写入html源代码

时间:2014-04-27 05:16:37

标签: php html web

我写了下面的代码来下载php程序中的文件:

if (isset($_GET["action"]) && $_GET["action"] == "GenerateExcel")
{
    $events = Activities::RetDaily($date);

    $file = "../temp/DailyReport.csv";
    header ("Content-Type: application/download");
    header ("Content-Disposition: attachment; filename=$file");
    header("Content-Length: " . ($fsize));
    readfile($file);
}

我使用下面的脚本提交表单:

function GenerateExcel()
{
    document.getElementById("Show").value = "<?php echo $showType ?>";
    document.getElementById("action").value= "GenerateExcel";
    document.getElementById("DailyReport").submit();
}

当我下载目标文件时,页面的html源代码附加到我的目标文件中!我该怎么做才能解决这个问题?

0 个答案:

没有答案