hi,

I am trying to learn how to upload multiple Music files to server then save information about them in database e.g. albumname, filename, type and maybe url. i have few questions:

1. would i be able to write the albumname in database as the folder i am uploading to. if so how?

2. how would i upload multiple files..

as i am a newbie can you guys please show me an example of this...

thanks

It's not as hard as you'd think.

Say that that you're creating a Pastebin. You'd have (simplified) the fields id, title, and filename. The filename could be random. For our purposes, $input is what the user is saving in the document, $title is the title, and we'll create the filename.

<?php

$title = mysql_real_escape_string($title);
$filename = rand(1,1000) . substr(0, 5, time());

mysql_query("INSERT INTO `pastebin`(title, filename) VALUES('$title', '$filename')");

$fh = fopen($filename . ".txt", +w);
fwrite($fh, $input);
fclose($fh);

?>

Of course, that's just creating it.

I got the answer to second question basically i will pass the id of textbox to insert.

but how would i actually write the url dynamically upon uploading, to database. say i am uploading into a folder called 'album1' 5 mp3s. now how would i insert in database album1/mp3.mp3, without hardcoding it like $path = "album1";

but how would i actually write the url dynamically upon uploading, to database. say i am uploading into a folder called 'album1' 5 mp3s. now how would i insert in database album1/mp3.mp3, without hardcoding it like $path = "album1";

Check move_uploaded_file . You have to specify the 'destination' where you want to upload the file. Use the same destination :-/ Right ?

This article has been dead for over six months. Start a new discussion instead.