Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/php/277.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
使用php readfile下载flash视频_Php_Flash_Readfile - Fatal编程技术网

使用php readfile下载flash视频

使用php readfile下载flash视频,php,flash,readfile,Php,Flash,Readfile,我正在尝试使用PHP的readfile()函数将flv视频下载到flash播放器,使用该函数我可以隐藏文件的位置。我尝试了这些代码,但jw播放器不起作用,文件可以单独下载,但不能和播放器一起使用 <?php $file = '/vid/myvideo.flv'; header('Content-Description: File Transfer'); header('Content-Type: video/x-flv'); header("Cache-Control: no-cache

我正在尝试使用PHP的readfile()函数将flv视频下载到flash播放器,使用该函数我可以隐藏文件的位置。我尝试了这些代码,但jw播放器不起作用,文件可以单独下载,但不能和播放器一起使用

<?php

$file = '/vid/myvideo.flv';
header('Content-Description: File Transfer');
header('Content-Type: video/x-flv');
header("Cache-Control: no-cache");
header('Content-Disposition: attachment; filename=myvideo.flv' );
header("Pragma: no-cache");
header('Content-length: '.filesize($file));

flush();
@readfile($file) or die("File not found.");
?>

当我传输.swf文件时,它可以工作,但文件的路径是可见的


是否可以使用readfile()函数将flv文件下载到flash player。

请尝试使用fread而不是使用readfile。这就是我目前的做法。它在我使用jwplayer的系统上工作。我用它作为参考。

下面是一些示例代码:
//create the header
header("Content-Type: video/x-flv");
header('Content-Length: ' . filesize($file));
//open the file
$fh = fopen($file, "rb");
ob_end_clean();
//start sending the file
while (!feof($fh)) {
    print(fread($fh, 8192));
}
//the file has been completely sent. close the file.
fclose($fh);

?>
然后,当您创建jwplayer时,下面是代码

$(document).ready(function(){
     jwplayer("mediaplayer").setup({
          flashplayer: "player.swf", 
          file: "/getFlv.php", //for this example, getFlv.php is located at www.domain.com/getFlv.php
          provider:'http'
     });
 });

“文件路径可见”是什么意思?在哪里可见?客户端中flv文件的路径它到底显示在哪里?它不会与播放机一起工作,因为播放机需要该路径。你所要求的是可能的,但我想你需要使用另一个播放器,或者写你自己的。。