Ho provato questa soluzione:
Codice PHP:
...
<a href="<?php htmlout($files['url']); ?>" target="black" onclick="download($files['url'],$files['filename'],$files['mimetype'])">
<?php htmlout($files['filename']); ?></a>
...
function download($path,$filename,$mimetype) {
try {
$disposition = 'inline';
if (file_exists($path)) {
//header('Content-Transfer-Encoding: binary');
//header('Last-Modified: ' . gmdate('D, d M Y H:i:s', filemtime($path)) . ' GMT');
//header('Accept-Ranges: bytes');
header('Content-Length: ' . filesize($path));
//header('Content-Encoding: none');
header("Content-Type: $mimetype");
header("Content-Disposition: $disposition; filename=" . $filename);
readfile($path);
} else {
echo "File not found on server";
}
} catch (Exception $e) {
$error = 'File non esistente, rimosso o non più disponibile.';
include $_SERVER['DOCUMENT_ROOT'] . '/filestorecms_includes/error.html.php';
exit();
}
exit();
}
...
ma non funziona. In pratica mi si apre una nuova finestra come se la funziona onlick nonci fosse.