How to Retrieve video files in php from database.....and how
to store video on database..

Answer Posted / rajasekhar

it is same like how to store file's into database

<?php
if($_POST['submit'] == 'submit')
{
$filename = $_FILES['video']['name'];
$tmpname = $_FILES['video']['tmp_name'];
$source = "upload/"; // this is a
folder in our server or system
$distination = "upload/".$filename; // we are
uploading file in to our created folder

if($_FILES['video']['error'] == false)
{
move_uploaded_file($tmpname,$distination);
}

// using sql we are upload file name into database,
$sql = mysql_query("insert into file set filename =
'".$filename."' ");

if($sql)
{
echo "file uploaded to database successfully";
}
else
{
echo "Unable to upload file to database. ".mysql_error();
}

// Retriveing file from that database

$sql = mysql_query("select * from file");
$res = mysql_fetch_array();

echo "upload/".$res['filename']; //when you like to play
the video, you has to use Embed tag
}
?>

<form name="frm" action="<?php $_SERVER['PHP_SELF']; ?>"
method="post" enctype="multipart/form-data">
<input type="file" name="video" /><input type="submit"
name="submit" value="submit" />
</form>

Is This Answer Correct ?    17 Yes 22 No



Post New Answer       View All Answers


Please Help Members By Posting Answers For Below Questions

How we get ip address of client, previous reference page etc?

551


What is exception handling in php?

1064


What are the string functions in php?

516


Which php framework is best for beginners?

500


How to block direct directory access in PHP?

547






What are the different errors in php?

556


What is difference between web service and api?

505


Suppose we receive a form submitted by a post to subscribe to a newsletter. This form has only one field, an input text field named email. How would we validate whether the field is empty? Print a message "the email cannot be empty" in this case?

652


What is the use of the function htmlentities?

617


What is the purpose of the php empty function?

486


How is php different from other languages?

470


Why namespace is used in php?

531


What is a variable cost example?

542


What is cookies? How to create cookies in php?

514


How can you execute php script from the command line?

542