Won't change mime type?

Permalink
Hey guys,

I'm trying to add more security to a block I built. Here's the code for a file I have in the /tools directory of the block:

<?php
   defined('C5_EXECUTE') or die(_("Access Denied."));
   $b = Block::getByID (intval ($_SERVER['QUERY_STRING']));
   $bp = new Permissions ($b);
   if ($b && $bp -> canRead () && strpos ($_SERVER['HTTP_REFERER'], BASE_URL . DIR_REL) > -1) {
      $c = $b -> getInstance ();
      $file = $c -> getFileObject();
      $mimeType = $file->getMimeType();
      $fc = Loader::helper('file');
      $contents = $fc->getContents($file->getPath());
      header("Content-type: $mimeType");
      print $contents;
      exit;
   } else {
      echo "Access Denied.";


The portion in the middle is an exact copy from some of the code used inside Concrete, and I'm sort of confused. When I debug the mime type variable comes up as blank, and the mime type of the response comes up as "text/html".

This messes up Flash Player, and it will not stream the video.

Do you know how I can fix this?

elyon
 
ScottC replied on at Permalink Reply
ScottC
i'd get the extension and figure out/switch the mime/type from that hard-coded, api is nice but isn't the end all be all.

-Scott
elyon replied on at Permalink Reply
elyon
HAH ...

My goodness, what an obvious answer.

Why wouldn't I hard code the mime type to be an FLV?

Thanks Scott :)