function download($path, $filename)
{
    ignore_user_abort(true);
    set_time_limit(0);
    // disable the time limit for this script
    //$path = "/Extern/Media/2. 만화/";
    //$path = "/absolute_path_to_your_files/"; // change the path to fit your websites document structure
    $dl_file = $filename;
    $fullPath = $path . $dl_file;
    if ($fd = fopen($fullPath, "r")) {
        $fsize = filesize($fullPath);
        $path_parts = pathinfo($fullPath);
        $ext = strtolower($path_parts["extension"]);
        switch ($ext) {
            case "zip":
                $ctype = "application/zip";
                break;
            case "rar":
                $ctype = "application/rar";
                break;
            default:
                $ctype = "application/force-download";
        }
        if (is_ie()) {
            $dl_file = utf2euc($dl_file);
        }
        header("Pragma: public");
        header("Expires: 0");
        //header("Cache-Control: must-revalidate, post-check=0, pre-check=0");
        header("Cache-Control: public");
        header("Content-Description: File Transfer");
        header("Content-Type: {$ctype}");
        $header = "Content-Disposition: attachment; filename='" . $dl_file . "';";
        header($header);
        header("Content-Transfer-Encoding: binary");
        header("Content-length: {$fsize}");
        ob_end_flush();
        while (!feof($fd)) {
            $buffer = fread($fd, 2048);
            echo $buffer;
        }
    } else {
        echo "fail " . $fullPath . "<br/>";
        exit;
    }
    fclose($fd);
    exit;
}
    $chr_code++;
}
$columns = implode(', ', $search);
$sql = "SELECT sur_created, " . $columns . "  FROM `g5_surveys_r` GROUP BY uniqid ";
$result = sql_query($sql);
$i = 2;
while ($data = sql_fetch_array($result)) {
    $value = array();
    $value['A' . $i] = $data['sur_created'];
    foreach ($fields as $field) {
        $value[$field . $i] = $data[$field];
    }
    $i++;
    array_push($values, $value);
}
$index = 2;
foreach ($values as $value) {
    $array_keys = array_keys($value);
    $objPHPExcel->getActiveSheet()->fromArray($value, NULL, 'A' . $index);
    $index++;
}
$filename = $surveys['su_subject'] . '_' . date('YmdHis') . '.xls';
if (is_ie()) {
    $filename = utf2euc($filename);
}
header('Content-Type: application/vnd.ms-excel;charset=utf-8');
header('Content-type: application/x-msexcel;charset=utf-8');
header('Content-Disposition: attachment;filename="' . $filename . '"');
header('Cache-Control: max-age=0');
$objWriter = PHPExcel_IOFactory::createWriter($objPHPExcel, 'Excel5');
$objWriter->save('php://output');