I'm building a video website and I want my users to be able to upload or embed videos from Youtube. The Youtube API doesn't seem to provide video upload from their website, or do they?
So I tried to embed videos via an iframe
with PHP. Here is the code:
<?php
$source=$_POST['source'];
?>
<html>
<div id="bo"><?php echo $source;?></div>
<form action="altupload.php" method="post">
<input type="text" name="source">
<input type="submit">
</form>
</html>
But all I get is:
<html><div id="bo"><iframe width=\"560\" height=\"315\" src=\"http://www.youtube.com/embed/tZa5hyb0_wA\" frameborder=\"0\" allowfullscreen></iframe></div>`
<html>
<form action="altupload.php" method="post">
<input type="text" name="source">
<input type="submit">
</form>
</html>
Can anyone recommend some other ways to do it? Thanks
You need to use the
addslashes()
function:Allow the user upload only youtube video ID from URL as :
video ID :
Vw5FDZRGTL0
and you can set other options of IFrame tag :
Good Luck