2 Replies Latest reply on Oct 9, 2014 4:40 AM by fmdataweb

    FileMaker PHP API - Container Data Download Filename

    fmdataweb

      I'm using the FileMaker PHP API and publshing container data via the web pages - this ia all working well so far.

       

      I'm using the containerBridge.php file that comes with the PHP API tutorial for generating the links for the container files - my only issue is with the name of the downloaded file. The files are downloaded/saved as:

       

      containerBridge.php.doc

      containerBridge.php.pdf

       

      instead of:

       

      Planning.doc

      Survey.pdf

       

      Does anyone know how to change the name of the file that is downloaded?

       

      In case it helps here's the main content of the containerBridge.php file:

       

       

      // Put the url in a variable

      $url = $_GET['path'];

       

       

      // Search for the extension of the file

      $url = substr($url, 0, strpos($url, "?"));

      $url = substr($url, strrpos($url, ".") + 1);

       

       

      // Send the correct Content-Type header

      if($url == "jpg"){

      header('Content-type: image/jpeg');

      } else if($url == "gif"){

      header('Content-type: image/gif');

      } else if($url == "doc"){

      header('Content-type: application/msword');

      } else if($url == "docx"){

      header('Content-type: application/msword');

      } else if($url == "xls"){

      header('Content-type: application/vnd.ms-excel');

      } else if($url == "xlsx"){

      header('Content-type: application/vnd.ms-excel');

      } else if($url == "png"){

      header('Content-type: image/png');

      } else if($url == "pdf"){

      header('Content-type: application/pdf');

      } else if($url == "mp3"){

      header('Content-type: audio/mpeg');

      // set default

      } else{

      header('Content-type: application/force-download');

      }

       

       

      echo $fm->getContainerData($_GET['path']);

       

      The links to download the file look like this:

       

      http://localhost/testing/containerBridge.php?path=%2Ffmi%2Fxml%2Fcnt%2FPlanning.doc%3F-db%3DDocuments%26amp%3B-lay%3DWebdocs%26amp%3B-recid%3D116%26amp%3B-field%3DContainer%281%29