我试图在页面上加载mp4文件,但是我收到了损坏的文件消息。
我使用这个作为我的php文件从根目录外的私人文件夹加载并直接从浏览器打开它,看看视频是否直接播放到firefox浏览器:
if(!empty($_GET['video']))
{
if (strpos($_GET['video'], "\0") !== FALSE) die('');
$video = $_REQUEST['video'];
$path_parts = pathinfo($video);
$file_name = $path_parts['basename'];
require_once("config.php");
if(isUserLoggedIn())
{
//Construct an Order object
$IsPaid = new Order($reference=$loggedInUser -> user_id,$pesapal_tracking_id=NULL,$orderstatus = NULL);
//Check if he is paid
if($IsPaid->isPaid())
{
//Private folder
$file = $_SERVER['DOCUMENT_ROOT'].'/../privatelogged/'. $file_name;
header("Expires: Mon, 26 Jul 1997 05:00:00 GMT");
header("Cache-Control: no-store, must-revalidate");
header("Content-Type: video/mp4");
header('Content-Length: ' . filesize($file));
set_time_limit(0);
$resource = @fopen($file,"rb");
while(!feof($resource))
{
print(@fread($resource, 1024*8));
ob_flush();
flush();
}
//readfile($file);
}
}
}