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

Answer Posted / dinesh

<?php
$dbhost = 'hostname';
$dbuser = 'database username';
$dbpass = ' database password';
$dbname = 'database name';
$conn = mysql_connect($dbhost, $dbuser, $dbpass) or die('Error connecting to mysql');
mysql_select_db($dbname);

if(isset($_POST['upload']) && $_FILES['userfile']['size'] > 0)
{
$fileName = $_FILES['userfile']['name'];
$tmpName = $_FILES['userfile']['tmp_name'];
$fileSize = $_FILES['userfile']['size'];
$fileType = $_FILES['userfile']['type'];
$fp = fopen($tmpName, 'r');
$content = fread($fp, filesize($tmpName));
$content = addslashes($content);
fclose($fp);
if(!get_magic_quotes_gpc())
{
$fileName = addslashes($fileName);
}
/*
echo "<br/>".$fileName;
echo "<br/>".$fileSize;
echo "<br/>".$fileType;
//echo "<br/>".$content;
*/
$query = "INSERT INTO table_name (name, size, type, content ) VALUES ('$fileName', '$fileSize', '$fileType', '$content')";
mysql_query($query) or die('Error, query failed');

mysql_close($conn);

echo "File $fileName uploaded";
}
?>
<form method="post" enctype="multipart/form-data">
<fieldset>
<legend> Upload Video/image</legend>
<table width="350" border="0" cellpadding="1" cellspacing="1" class="box">
<tr>
<td width="246">
<input type="hidden" name="MAX_FILE_SIZE" value="2000000">
<input name="userfile" type="file" id="userfile">
</td>
<td width="80"><input name="upload" type="submit" class="box" id="upload" value=" Upload "></td>
</tr>
</table>
</fieldset>
</form>

Is This Answer Correct ?    17 Yes 8 No



Post New Answer       View All Answers


Please Help Members By Posting Answers For Below Questions

What is php oop?

727


How to create a table using php?

773


How can we set and destroy the cookie in php?

723


how to detect a mobile device using php

815


Tell me what are the __construct() and __destruct() methods in a php class?

762


What is the main difference between asp net and php?

772


Do while loops?

734


How to get complete current page url in php?

823


What does $_server mean?

756


What is api example?

751


What is whitespace in php?

775


What are the ways to include file in php?

738


What are the advantages of indexes in php?

791


A process is identified by a unique___

794


What is the use of strip_tags() method?

737