Click here to Skip to main content
15,881,248 members
Please Sign up or sign in to vote.
1.00/5 (3 votes)
See more:
hi.... I am a new user of asp.net... I just understood that it is better to save the files(images,video,audio) in data directory, than store them as in binary form because it will help to reduce memory usage.. I need codes for,


1.upload files(images,video,audio) into data directory
2.insert path of files(images,video,audio) in the directory into database
3.retrieve & view files(images,video,audio)

Can anyone help me????
Thanks in advance...
Posted
Updated 10-Dec-13 8:15am
v3
Comments
OriginalGriff 10-Dec-13 11:00am    
What have you tried?
Where are you stuck?
Sergey Alexandrovich Kryukov 10-Dec-13 11:35am    
This is not a question ("Can anyone help?" does not count, of course. How anyone can answer it? "Yes, I can!"? :-).
What have you tried so far? (Read this article!) What's the problem?
—SA
developersend 10-Dec-13 15:32pm    
0)
{
echo "Return Code: " . $_FILES["file"]["error"] . "<br />";
}
else
{
if (file_exists("upload/" . $_FILES["file"]["name"]))
{
echo $_FILES["file"]["name"] . " already exists. ";
}
else
{
move_uploaded_file($_FILES["file"]["tmp_name"],
"upload/" . $_FILES["file"]["name"]);
}
}
}
else
{
echo "Invalid file";
}
mysql_close($con);
?>

hope this link help you retrieve binary image from database[^]
Another link here convert image to binary[^]
 
Share this answer
 
v2
ASP
$a=$_FILES["file"]["name"];

$con = mysql_connect("localhost","root","");

if (!$con)
  {
  die('Could not connect: ' . mysql_error());
  }
  
mysql_select_db("film", $con);
mysql_query("INSERT INTO member (filmname,content,pic_name) 
VALUES('$_POST[fn]','$_POST[t1]','$a')");

if ((($_FILES["file"]["type"] == "image/gif")
|| ($_FILES["file"]["type"] == "image/jpeg")
|| ($_FILES["file"]["type"] == "image/jpg"))
&& ($_FILES["file"]["size"] < 20000000))
  {
  if ($_FILES["file"]["error"] > 0)
    {
    echo "Return Code: " . $_FILES["file"]["error"] . "<br />";
    }
  else
    {
    if (file_exists("upload/" . $_FILES["file"]["name"]))
      {
      echo $_FILES["file"]["name"] . " already exists. ";
      }
    else
      {
      move_uploaded_file($_FILES["file"]["tmp_name"],
      "upload/" . $_FILES["file"]["name"]);
      }
    }
  }
else
  {
  echo "Invalid file";
  }
mysql_close($con);
?>
 
Share this answer
 
v2

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900