topical media & game development

talk show tell print

professional-sql-07-public-files-view.php / php



  <?php
  // include shared code
  include '../lib/config.php';
  
  // make sure users only access files in the albums
  file = (isset(_GET['file'])) ? (BASEDIR . '/' . _GET['file']) : '';
  if (file && strpos(realpath(file), BASEDIR) === 0 && file_exists(file))
  {
      // dump file content to browser
      switch(substr(file, strrpos(file, '.') + 1))
      {
          // file is jpeg image
          case 'jpg':
          case 'jpeg':
              header('Content-Type: image/jpeg');
              readfile(file);
              break;
  
          // file is quicktime movie
          case 'mov':
              header('Content-Type: movie/quicktime');
              readfile(file);
      }
  }
  ?>
  


(C) Æliens 20/2/2008

You may not copy or print any of this material without explicit permission of the author or the publisher. In case of other copyright issues, contact the author.