Laim
08-16-2013, 02:01 AM
Basically, I've learned PHP, XML, HTML, CSS, Javascript etc however I never got down to learning MySQL and kind of just forgot about it. However a few days ago I got a client asking if I could make them a 'Video Host' so certain people could upload videos. (Much like YouTube.) She wanted Search etc and sadly, that needs MySQL. I had to reject her simply because I was to lazy to learn it. Now I'm learning it I'm completely stumped! :confused:
I decided to throw myself in the deep end and try to something like what she requested, so far I've achieved being able to log information in a database and put the file (movie.mp4) in a directory. However now I'd like to store the files in the directory too so I don't use a unneeded amount of server space. The code I currently have to upload the file and and store the information in the database (and the file in its directory) is as follows.
if(isset($_POST['submit']))
{
$name = $_FILES['file']['name'];
$temp = $_FILES['file']['tmp_name'];
move_uploaded_file($temp,"uploaded/".$name);
$url = "uploaded/$name";
mysql_query("INSERT INTO `videos` VALUE ('','$name','$url')");
}
I know it's not the nicest looking code, but for now I'd rather get it working then mess with how it looks. Anyway.
I was wondering if they're was anyway to move the TEMP file into the database? much like how you do it with the NAME of the file. Any help with this is much appreciated as I've been stuck at this since Yesterday.
I decided to throw myself in the deep end and try to something like what she requested, so far I've achieved being able to log information in a database and put the file (movie.mp4) in a directory. However now I'd like to store the files in the directory too so I don't use a unneeded amount of server space. The code I currently have to upload the file and and store the information in the database (and the file in its directory) is as follows.
if(isset($_POST['submit']))
{
$name = $_FILES['file']['name'];
$temp = $_FILES['file']['tmp_name'];
move_uploaded_file($temp,"uploaded/".$name);
$url = "uploaded/$name";
mysql_query("INSERT INTO `videos` VALUE ('','$name','$url')");
}
I know it's not the nicest looking code, but for now I'd rather get it working then mess with how it looks. Anyway.
I was wondering if they're was anyway to move the TEMP file into the database? much like how you do it with the NAME of the file. Any help with this is much appreciated as I've been stuck at this since Yesterday.