adspace


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 does $_files means?

1162


if you run the app program all vendor open items are cleared but is it possible to reverse the again again open items please tell me the answer

1989


How to create a web form?

1111


sort term descripttion form, report and uery

2254


How to calculate the difference between two dates using php?

1144


Which variable declarations within a class is invalid in php?

1048


hello all, I need some sample placement papers in lion bridge.. can anyone help me?

2177


What is difference between static and final in php?

1109


What is the difference between htmlentities() and htmlspecialchars()?

1091


Tell me what kind of things have you done on the social side?

1065


What is the current stable version of php?

1124


How can we extract string "pcds.co.in" from a string "https://info@pcds.co.in" using regular expression of php? More on reg can you explain

1078


List some features of php that are deprecated in php7?

1024


What is the current stable version of php? What advance thing in php7?

1095


Write a program using while loop?

1118