Follow Our FB Page << CircleMedia.in >> for Daily Laughter. We Post Funny, Viral, Comedy Videos, Memes, Vines...


How to upload any files extension in our database
Ex.(.doc,.txt,mp4,mp3 etc.)in php



How to upload any files extension in our database Ex.(.doc,.txt,mp4,mp3 etc.)in php..

Answer / rajasekhar

It is so simple

first take a form to upload any extension file, your self

<?php
if($_POST['submit'] == 'submit')
{
$filename = $_FILES['file']['name'];
$tmpname = $_FILES['file']['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['file']['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'];
}
?>


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

Is This Answer Correct ?    3 Yes 3 No

Post New Answer

More PHP Interview Questions

How can we extract string 'techinterviews.com' from a string 'http://www.techinterviews.com' using regular expression in PHP?

4 Answers  


Explain what is smarty?

0 Answers  


How do you match the character ^ at the beginning of the string? - ^^

1 Answers  


What is ci in php?

0 Answers  


What is the basic function to search files for lines (or other units of text) that contain a pattern.

0 Answers  






How many Types of COmments are there in PHP and what are they?

4 Answers  


What is mod_php?

0 Answers  


Php says that an array is an ordered map. But how the values are ordered in an array?

0 Answers  


What is mysqli php?

0 Answers  


Can php replace javascript?

0 Answers  


how to run PHP in command line?

8 Answers   InfoShore, Ramp Green, Xtreeme,


Why do we use query?

0 Answers  






Categories