test_file.php 328 B

123456789101112131415161718
  1. <?php
  2. $test = Test::get($id);
  3. if(!$test) throw new Exception("Test not found.");
  4. $directory = $test->getDirectory();
  5. $path = $directory . "/" . $name . ".jpg";
  6. if(file_exists($path)) {
  7. header("Content-Type: image/jpeg");
  8. readfile($path);
  9. }
  10. else {
  11. header("Content-Type: image/png");
  12. readfile("public/img/blank.png");
  13. }
  14. ?>