Golgappa.net | Golgappa.org | BagIndia.net | BodyIndia.Com | CabIndia.net | CarsBikes.net | CarsBikes.org | CashIndia.net | ConsumerIndia.net | CookingIndia.net | DataIndia.net | DealIndia.net | EmailIndia.net | FirstTablet.com | FirstTourist.com | ForsaleIndia.net | IndiaBody.Com | IndiaCab.net | IndiaCash.net | IndiaModel.net | KidForum.net | OfficeIndia.net | PaysIndia.com | RestaurantIndia.net | RestaurantsIndia.net | SaleForum.net | SellForum.net | SoldIndia.com | StarIndia.net | TomatoCab.com | TomatoCabs.com | TownIndia.com
Interested to Buy Any Domain ? << Click Here >> for more details...

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

Answer Posted / 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       View All Answers


Please Help Members By Posting Answers For Below Questions

What is a query give example?

1053


Suppose the variable $var1 is set to 10 and the $var2 is set to the character var1, what's the value of $$var2?

1003


Why do we use cookie?

1024


What is difference between echo and print_r in php?

949


What is the php function that removes the last element of the array and returns it?

1011


Explain the difference between array_merge() and array_combine()?

1053


Why do we use inheritance in php?

1106


What is the use session in php?

1089


What are the characteristics of php?

1131


How error handling is being handled by php?

1103


What is repository in php?

1063


What is a substring in php?

1132


What is the difference between htmlentities and htmlspecialchars in php?

1102


Explain the syntax for ‘foreach’ loop with example.

1005


What is php namespace?

1036