473,404 Members | 2,114 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,404 software developers and data experts.

How to upload videos in database?

I don,t know how can upload videos in database and retrive
to the database

Videos cant save in videos folder.

------
update

so what can i do which place i change
Expand|Select|Wrap|Line Numbers
  1. <?php
  2.  
  3. if ($_POST["action"] == "Load")
  4. {
  5. $folder = "videos/";
  6.  
  7.  
  8.  
  9. move_uploaded_file($_FILES["filep"]["tmp_name"] , "$folder".$_FILES["filep"]["name"]);
  10.  
  11. echo "<p align=center>File ".$_FILES["filep"]["name"]."loaded...";
  12.  
  13. $result = mysql_connect("localhost", "root", "") or die ("Could not save  name Error: " . mysql_error());
  14. mysql_select_db("v1") or die("Could not select database");
  15. mysql_query("INSERT into video (URL) VALUES('".$_FILES['filep']['name']."')");
  16.  
  17. if($result) { echo "Video name saved into database"; 
  18.     echo "<a href='retrivevideos.php'><input type='button' value='Retrive'></a>";
  19. }
  20. else {
  21.  
  22. //Gives and error if its not
  23. echo "Sorry, there was a problem uploading your file.";
  24. }
  25. }
  26. ?>
Jul 24 '12 #1

✓ answered by Exequiel

Expand|Select|Wrap|Line Numbers
  1. <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
  2. <html xmlns="http://www.facebook.com/exequiel.s.vibar">
  3. <head>
  4. <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
  5. <title>Sampol upload ni zick</title>
  6. </head>
  7. <?php
  8. include'connect_to_db.php';//connection to database
  9. ?>
  10. <body>
  11. <br><br>
  12. <center>
  13. <?php
  14. //code for uploading videos...
  15. if(isset($_POST['video'])){//button for Upload
  16. $target = "uploaded_folder/"; //folder where to save the uploaded file/video
  17.  $target = $target . basename( $_FILES['uploaded']['name']) ; //gets the name of the upload file
  18.  $ok=1; 
  19.  if(move_uploaded_file($_FILES['uploaded']['tmp_name'], $target)) 
  20.  {
  21.      $query =mysql_query( "INSERT INTO tbl_video(video_name) VALUES ('$target')");//insertion to database
  22.  
  23.  echo "The file ". basename( $_FILES['uploadedfile']['name']). " has been uploaded";
  24.  } 
  25.  else {
  26.  echo "Sorry, there was a problem uploading your file.";
  27.  }
  28. }
  29.  ?>
  30.  
  31.  <form enctype="multipart/form-data" method="POST">
  32.      Please choose a file: <input name="uploaded" type="file" /><br />
  33.      <input type="submit" value="Upload" name="video"/>
  34.  </form> 
  35.  
  36. <br><br>
  37. <br>
  38. </center>
  39. </body>
  40. </html>
you can upload any files in this code, because we did not restrict the file extension...

12 20610
lyodmichael
75 64KB
you dont need to upload the upload the video you just need to get the address and save it in database.
Jul 24 '12 #2
Exequiel
288 256MB
if you already tried to upload an image, the way on how to upload an image is just the same on how to upload a video. Only the file extension is the difference.
Jul 24 '12 #3
Exequiel
288 256MB
Expand|Select|Wrap|Line Numbers
  1. <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
  2. <html xmlns="http://www.facebook.com/exequiel.s.vibar">
  3. <head>
  4. <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
  5. <title>Sampol upload ni zick</title>
  6. </head>
  7. <?php
  8. include'connect_to_db.php';//connection to database
  9. ?>
  10. <body>
  11. <br><br>
  12. <center>
  13. <?php
  14. //code for uploading videos...
  15. if(isset($_POST['video'])){//button for Upload
  16. $target = "uploaded_folder/"; //folder where to save the uploaded file/video
  17.  $target = $target . basename( $_FILES['uploaded']['name']) ; //gets the name of the upload file
  18.  $ok=1; 
  19.  if(move_uploaded_file($_FILES['uploaded']['tmp_name'], $target)) 
  20.  {
  21.      $query =mysql_query( "INSERT INTO tbl_video(video_name) VALUES ('$target')");//insertion to database
  22.  
  23.  echo "The file ". basename( $_FILES['uploadedfile']['name']). " has been uploaded";
  24.  } 
  25.  else {
  26.  echo "Sorry, there was a problem uploading your file.";
  27.  }
  28. }
  29.  ?>
  30.  
  31.  <form enctype="multipart/form-data" method="POST">
  32.      Please choose a file: <input name="uploaded" type="file" /><br />
  33.      <input type="submit" value="Upload" name="video"/>
  34.  </form> 
  35.  
  36. <br><br>
  37. <br>
  38. </center>
  39. </body>
  40. </html>
you can upload any files in this code, because we did not restrict the file extension...
Jul 26 '12 #4
ok thanks Exequiel for given code.

how i retrieve video in database if any idea or code please give me
Jul 26 '12 #5
hay Exequiel in this code do not upload videos?why
and not save path in database but any other file uploaded
Jul 26 '12 #6
hemaldazzle it works.
include'connect_to_db.php';
maybe, error in this line.
Jul 26 '12 #7
yes that is work but not upload video in upload folder and database
Jul 26 '12 #8
you check file upload limit. it should work.
Jul 26 '12 #9
Exequiel
288 256MB
Expand|Select|Wrap|Line Numbers
  1. <?php
  2. $con=mysql_connect("localhost","root","") or die ("COULD NOT CONNECT TO YOUR DATABASE!");
  3. mysql_select_db("upload_sample",$con);
  4. ?>
try this code for the connection to your database, save it as connect_to_db.php,
Jul 27 '12 #10
Exequiel
288 256MB
you can retrieve the video in db by its file name and Id. and you must set the destination of your uploaded file, example,

../uploaded_folder/$var_for_filename; //the destination where the uploaded file(s) being saved and its file name. try it in sql .
Jul 27 '12 #11
Exequiel
288 256MB
Download this file. . . http://www.mediafire.com/?1iyj7efan98jj0a. . . and try to run. . .:)
Jul 27 '12 #12
computerfox
276 100+
I was actually just about to say that. I don't suggest uploading a video into a database as in a multimedia database because you would need to use a blob, which is difficult to deal with. You'll want to use that form script that was provided, make sure that you allow users to upload the correct size for the files, make sure that the directory is read/write=777, and you copy the URL into the database as a text. What I even suggest is maybe generating a random name before completing the script (this would most likely require a rename at the end of the script), but this part is not mandatory. All you really need is the file name and know where the videos would be stored.

Hope that helps!
Jul 30 '12 #13

Sign in to post your reply or Sign up for a free account.

Similar topics

3
by: R Reyes | last post by:
what are the pros/cons of uploading a file into a database (like access, sql server, oracle) vs. uploading a file into a folder (and only storing its path in a database table) ? i've never had...
4
by: Mattias | last post by:
Hi I am building a simple database system in MS Access 2002 and would like to create a command button that upon clicking transfers the current mdb-file to an ftp-server. Is there a solution for...
3
by: AHMLIVE | last post by:
Hi everyone. I got a problem when i tried to upload MYSQL database. I don't have any idea how to upload it. It is my first time to do it. I already upload the pages from my local pc to server...
0
ammoos
by: ammoos | last post by:
hiiii friends...i want to upload some selected mysql datarecords from my offline system which is written in vb to online system which is made by asp.net with vb. i also want to make some processing...
0
by: nirbhay | last post by:
I am using Asp.net 1.1 with Back end as C# i want to Use CSV file Validate it and upload to Database sql server 2K with all error check...Validation of Fields etc
1
xxoulmate
by: xxoulmate | last post by:
how to upload a database on the mysql server., i am using mysql version 4.0.1 that database is not yet existing in the server. and that database in a format of file.sql(came from a mysqldump)
3
by: creative1 | last post by:
Hello everyone, I am working on a site that provide a facility to downlaod videos , available on the server (only to a specific group of members). There should be afacilty to uplaod videos through...
7
by: dragiton | last post by:
SA Upload SQL Database variable types (image upload and storage) I am having trouble with the SA Upload utility. The following code used to work correctly. However, I lost my database and had to...
0
by: ahmurad | last post by:
Dear Brothers, I want to upload XLS/CSV huge data (90,000 rows in a XLS/CSV file) into MYSQL database. I want to use only Import option of phpmyadmin to upload XLS/CSV files. How can i to...
12
by: neelsbr | last post by:
how to upload mysql database to my server space (hostgator,bluehost) in programming method.any one can help me to do this. Thanks in Advance
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.