问题
My file download works great. The file is delivered correctly. But I want to make it prettier.
Is there a way to set a favicon and a window title, if I click on a html-download link to a file in a new tab?
the file is generated and streamed by php.
client part:
<a target="_blank" tabindex="0" href="/path/to/file-download/interface" >
server stream, while $file
is some array holding file information:
if (file_exists($file['path'])) {
$finfo = finfo_open(FILEINFO_MIME_TYPE);
$mime = finfo_file($finfo, $file['path']);
if( strstr($mime, "image") !== false ){
header('Content-Type: '.$mime);
header('Content-Disposition: filename='.basename($file['path']));
} else {
header('Content-Description: File Transfer');
header('Content-Type: application/octet-stream');
header('Content-Disposition: attachment; filename='.basename($file['path']));
}
header('Content-Transfer-Encoding: binary');
header('Expires: 0');
header('Cache-Control: must-revalidate, post-check=0, pre-check=0');
header('Pragma: public');
header('Content-Length: ' . filesize($file['path']));
ob_clean();
flush();
readfile($file['path']);
exit;
} else {
error_log("File for download >".$file['path']."< not found.");
return false;
}
UPDATE An additional problem is, that there is a favicon already in the root folder, but I want to show a different one.
来源:https://stackoverflow.com/questions/44002043/html-file-download-controle-favicon-and-tab-title