Commit ac0ce9d5 by Scott

Filename for image downloads

parent 322011e9
...@@ -51,8 +51,7 @@ if (isset($blob)) { ...@@ -51,8 +51,7 @@ if (isset($blob)) {
// allows browsers and proxies to cache the blob (30 days) // allows browsers and proxies to cache the blob (30 days)
header('Cache-Control: max-age=2592000, public'); header('Cache-Control: max-age=2592000, public');
// for compatibility with HTTP headers and all browsers $disposition = 'inline';
$filename = preg_replace('/[^A-Za-z0-9 \\._-]/', '-', $blob['filename']);
switch ($blob['format']) { switch ($blob['format']) {
case 'jpeg': case 'jpeg':
...@@ -70,7 +69,6 @@ if (isset($blob)) { ...@@ -70,7 +69,6 @@ if (isset($blob)) {
case 'pdf': case 'pdf':
header('Content-Type: application/pdf'); header('Content-Type: application/pdf');
header('Content-Disposition: inline; filename="'.$filename.'"');
break; break;
case 'swf': case 'swf':
...@@ -79,10 +77,14 @@ if (isset($blob)) { ...@@ -79,10 +77,14 @@ if (isset($blob)) {
default: default:
header('Content-Type: application/octet-stream'); header('Content-Type: application/octet-stream');
header('Content-Disposition: attachment; filename="'.$filename.'"'); $disposition = 'attachment';
break; break;
} }
// for compatibility with HTTP headers and all browsers
$filename = preg_replace('/[^A-Za-z0-9 \\._-]+/', '', $blob['filename']);
header('Content-Disposition: '.$disposition.'; filename="'.$filename.'"');
echo $blob['content']; echo $blob['content'];
} else { } else {
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment