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 to get no. of rows using MYSQL function?

798


What is file upload?

809


Is it possible to extend the execution time of a php script?

742


Tell me how to initiate a session in php?

759


What does $globals mean?

739


Explain how can php and javascript interact?

745


How to set a page as a home page in a php based site?

720


What are the advantages of stored procedures, triggers, indexes in php?

763


What is the difference between get and post method in php?

718


Is php pass by reference or value?

763


What is the difference between a session and cookies?

717


What is regular expression in php?

755


How to delete file in php?

725


How can we submit from without a submit button?

763


Which is not a php magic constant?

785