Ejemplo n.º 1
0
                download_file($file_info['path'], $file_name, $content_type);
            }
        }
    } catch (Exception $e) {
        req_not_found();
    }
} else {
    if (function_exists('get_download_data')) {
        $content_info = '';
        try {
            get_download_data($content_info);
            if (!$content_info) {
                req_not_found();
            } else {
                if (is_array($content_info)) {
                    $content_type = isset($content_info['content_type']) ? $content_info['content_type'] : "application/force-download";
                    $file_name = isset($content_info['name']) ? $content_info['name'] : 'download.dat';
                    set_output_file($file_name, $content_type, true, strlen($content_info['data']));
                    echo $content_info['data'];
                } else {
                    set_output_file('download.dat');
                    echo $content_info;
                }
            }
        } catch (Exception $e) {
            req_not_found();
        }
    } else {
        req_not_found();
    }
}
Ejemplo n.º 2
0
Archivo: common.php Proyecto: steem/qwp
function download_file($file_path, $file_name, $content_type = "application/x-download", $attachment = true)
{
    if (file_exists($file_path)) {
        $file_size = filesize($file_path);
        header('Content-Description: File Transfer');
        header("Content-type: " . $content_type);
        header("Content-Transfer-Encoding: Binary");
        no_cache();
        header('Pragma: public');
        if ($attachment) {
            header('Content-Disposition: attachment; filename=' . $file_name);
        }
        header('Content-length: ' . $file_size);
        readfile($file_path);
    } else {
        req_not_found();
    }
}