12345678910111213141516171819202122232425262728293031323334353637383940414243 |
- <?php
- if (!defined('GNUSOCIAL')) { exit(1); }
- class Attachment_downloadAction extends AttachmentAction
- {
- public function showPage()
- {
-
- $filepath = $this->attachment->getFileOrThumbnailPath();
- $filesize = $this->attachment->getFileOrThumbnailSize();
- $mimetype = $this->attachment->getFileOrThumbnailMimetype();
- if (empty($filepath)) {
- $this->clientError(_('No such attachment'), 404);
- }
- $filename = MediaFile::getDisplayName($this->attachment);
-
-
-
- @ini_set('display_errors', 0);
- header("Content-Description: File Transfer");
- header("Content-Type: {$mimetype}");
- header("Content-Disposition: attachment; filename=\"{$filename}\"");
- header('Expires: 0');
- header('Content-Transfer-Encoding: binary');
- AttachmentAction::sendFile($filepath, $filesize);
- }
- }
|