attachment_download.php 1.1 KB

1234567891011121314151617181920212223242526272829303132
  1. <?php
  2. if (!defined('GNUSOCIAL')) { exit(1); }
  3. /**
  4. * Download notice attachment
  5. *
  6. * @category Personal
  7. * @package GNUsocial
  8. * @author Mikael Nordfeldth <mmn@hethane.se>
  9. * @license https://www.gnu.org/licenses/agpl-3.0.html GNU Affero General Public License version 3.0
  10. * @link https:/gnu.io/social
  11. */
  12. class Attachment_downloadAction extends AttachmentAction
  13. {
  14. public function showPage(): void
  15. {
  16. // Disable errors, to not mess with the file contents (suppress errors in case access to this
  17. // function is blocked, like in some shared hosts). Automatically reset at the end of the
  18. // script execution, and we don't want to have any more errors until then, so don't reset it
  19. @ini_set('display_errors', 0);
  20. header("Content-Description: File Transfer");
  21. header("Content-Type: {$this->mimetype}");
  22. header("Content-Disposition: attachment; filename=\"{$this->filename}\"");
  23. header('Expires: 0');
  24. header('Content-Transfer-Encoding: binary'); // FIXME? Can this be different?
  25. parent::sendFile();
  26. }
  27. }