Location: PHPKode > projects > Ajax File Manager - AjaxExplorer > ajaxexplorer/script/download.php
<?php

/*
AjaxExplorer Copyright (C) 2007-2008 Syed Mohammad Sidque Tahir Al-Habshi

This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.

This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. Head to
GNU site http://www.gnu.org/licenses/ for license copy.
*/

if(Post('download'))
{
  if($userid && $perm>7)
  {
    if(file_exists($file=$root.Post('dirc').Post('download')))
    {
      $part=explode('.', Post('download'));
      switch($exts=$part[(count($part)-1)])
      {
	case 'bmp': case 'gif': case 'jpg': case 'png':
	  header('Content-Type: image/'.$exts);
	  break;

	default:
	  header('Content-Type: application/'.$exts);
	  break;
      }

      header('Content-Disposition: attachment; filename="'.Post('download').'"');
      readfile($file);
      exit;
    }
  }
  else $text='top.alert(\'You do not have the permission!\');';
}

?>
Return current item: Ajax File Manager - AjaxExplorer