Solved

PHP will not open MPG file for embed

Posted on 2009-06-28
3
306 Views
Last Modified: 2013-12-13
I have files stored outside of the document root for obvious security reasons. I am trying to add an element where I can view the videos in my folder. But when I try to fopen() the .mpg file it will not play the video. I have tried just putting the straight video in there but it will not be in the document root once its live, and also, I want a PHP file to read the file for also security purposes.

Below is my code:

Thanks.
Video Player Page:
----------------------------------------------------------
Video:<br />
<embed src="video/index.php?id=2" width="320" height="250" CONTROLLER="true" LOOP="false" AUTOPLAY="false" name="Random Video"></embed>
 
 
PHP Page:
<?php
header("Content-Type: video/mpeg");
		header("Content-Transfer-Encoding: binary");
		$fp=fopen("../../../videos/userid/Linking Park - In the End - Music Video.mpg", "r");
		if ($fp)
		fpassthru($fp);
?>

Open in new window

0
Comment
Question by:qrpike
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
3 Comments
 
LVL 4

Accepted Solution

by:
tokyoahead earned 400 total points
ID: 24733574
1. does it work if you put the video inside public_html?

No? Try to fix the video page first.
Yes? Step 2.

2. Does your php code actually access & read the file? is the path correct etc?

No? check the path and spelling.
Yes? Step 3.

3. Are you sure you are using the correct code to passthe file to the website and the correct headers?
I am not familiar with the required headers. Filesize might be necessary and others. If you call the php page yourself with the browser, does it offer the mpg file for download?




0
 
LVL 14

Assisted Solution

by:profya
profya earned 100 total points
ID: 24736548
In your php.ini make sure that open_basedir is not enabled.
0
 

Author Comment

by:qrpike
ID: 24736562
I fixed it.

I had to include every header I could think of, about 9-10 in all.

Thanks guys.
0

Featured Post

Turn your laptop into a mobile console!

The CV211 Laptop USB Console Adapter provides a direct Laptop-to-Computer connection for fast and easy remote desktop access with no software to install.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Since pre-biblical times, humans have sought ways to keep secrets, and share the secrets selectively.  This article explores the ways PHP can be used to hide and encrypt information.
Introduction This article is intended for those who are new to PHP error handling (https://www.experts-exchange.com/articles/11769/And-by-the-way-I-am-New-to-PHP.html).  It addresses one of the most common problems that plague beginning PHP develop…
The viewer will learn how to create and use a small PHP class to apply a watermark to an image. This video shows the viewer the setup for the PHP watermark as well as important coding language. Continue to Part 2 to learn the core code used in creat…
The viewer will learn how to create a basic form using some HTML5 and PHP for later processing. Set up your basic HTML file. Open your form tag and set the method and action attributes.: (CODE) Set up your first few inputs one for the name and …

695 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question