This script uses fpassthru() to load a quicktime movie that is outside of the document root. I am using an embedded image tag to call this php script. The url looks like this.

movie.php?fileID=3

When the quicktime movie player loads the movie does not start playing. All I see is the blue broken image Q in the browser. Please look at my code and tell me why it won't load.

<?php
ob_start();
session_start();

include '../include/db.inc';
include '../include/error.inc';
include '../include/include.inc';
include '../include/generalQuery.inc';
//include '../include/databaseUpdates.inc';

set_error_handler("errorHandler");

// Open a connection to the DBMS
if (!($connection = @ mysql_pconnect($hostName,
                                     $username,
                                     $password)))
     showerror();

if (!mysql_select_db($databaseName, $connection))
     showerror();

// query the download table
generalQuery($connection, "downloads");

// get the results of the query from the session and unset the session		  
$result = $_SESSION['result']; unset($_SESSION['result']); // fetch the row $row = @ mysql_fetch_assoc($result); $fileDir = $row['file_path']; // supply a path name. $fileName = $row['file_name']; // supply a file name. $fileString = $fileDir . '/' . $fileName; // combine the path and file // translate file name properly for Internet Explorer. if (strstr($_SERVER['HTTP_USER_AGENT'], "MSIE")){ $fileName = preg_replace('/\./', '%2e', $fileName, substr_count($fileName, '.') - 1); } // make sure the file exists before sending headers if(!$fdl=@fopen($fileString,'r')){ die("Cannot Open File!"); } else { //Close the session to allow for header() to be sent header("Content-Type: video/quicktime"); fpassthru($fdl); // increment the download counter //databaseUpdates(&$connection, "downloads"); } ob_end_flush(); ?>

    Have you tried commenting out your set_error_handler() param (so that the default PHP error messages are shown), setting error_reporting to E_ALL, and opening this script directly in your browser? Perhaps PHP is trying to tell you what's wrong...

    Also, remove all of the '@' error suppressors for debugging purposes.

      I commented out the error handler and I still have the same problem. I will try commenting out the @. I am trying to pass a 13 MB file. Would it be better for me to store the file in the database and just echo it out with a header? How many MB does mediumblob and largeblob store? How do I set error_reporting to E_ALL?

        Instead of this:

        fpassthru($fdl); 

        try this:

        while(!feof($fdl)) {
           echo fread($fdl, 8192);
        }

        In addition, do not use output buffering.

          I tried the feof loop and it seems like right when I added it to my script it worked, I think. But right now I can't seem to make it work. I want to store my files outside of the document root for security reasons. Does fread work for files that are outside of the document root. My other option is to store the files in the database, although one of the files is a 13MB quick time movie. I am not sure if it would be good to store a 13MB quicktime movie in the database. I have access to the php.ini file so I can make the nesecary changes there to so that I can upload a file that big.

          What is the best way to do this that will work?

            Write a Reply...