Du kan inte välja fler än 25 ämnen Ämnen måste starta med en bokstav eller siffra, kan innehålla bindestreck ('-') och vara max 35 tecken långa.

download.php 1.7KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950
  1. <?php
  2. /**
  3. * @author Andreas Fischer <bantu@owncloud.com>
  4. * @author Felix Moeller <mail@felixmoeller.de>
  5. * @author Frank Karlitschek <frank@owncloud.org>
  6. * @author Jakob Sack <mail@jakobsack.de>
  7. * @author Lukas Reschke <lukas@owncloud.com>
  8. * @author Morris Jobke <hey@morrisjobke.de>
  9. * @author Robin Appelman <icewind@owncloud.com>
  10. * @author Vincent Petry <pvince81@owncloud.com>
  11. *
  12. * @copyright Copyright (c) 2015, ownCloud, Inc.
  13. * @license AGPL-3.0
  14. *
  15. * This code is free software: you can redistribute it and/or modify
  16. * it under the terms of the GNU Affero General Public License, version 3,
  17. * as published by the Free Software Foundation.
  18. *
  19. * This program is distributed in the hope that it will be useful,
  20. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  21. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  22. * GNU Affero General Public License for more details.
  23. *
  24. * You should have received a copy of the GNU Affero General Public License, version 3,
  25. * along with this program. If not, see <http://www.gnu.org/licenses/>
  26. *
  27. */
  28. // Check if we are a user
  29. OCP\User::checkLoggedIn();
  30. $filename = $_GET["file"];
  31. if(!\OC\Files\Filesystem::file_exists($filename)) {
  32. header("HTTP/1.0 404 Not Found");
  33. $tmpl = new OCP\Template( '', '404', 'guest' );
  34. $tmpl->assign('file', $filename);
  35. $tmpl->printPage();
  36. exit;
  37. }
  38. $ftype=\OC_Helper::getSecureMimeType(\OC\Files\Filesystem::getMimeType( $filename ));
  39. header('Content-Type:'.$ftype);
  40. OCP\Response::setContentDispositionHeader(basename($filename), 'attachment');
  41. OCP\Response::disableCaching();
  42. OCP\Response::setContentLengthHeader(\OC\Files\Filesystem::filesize($filename));
  43. OC_Util::obEnd();
  44. \OC\Files\Filesystem::readfile( $filename );