Page 1 of 1
MP3 upload form
Posted: Sun Mar 30, 2003 5:30 pm
by thoughtriot
I know how to upload image files using a form and php, but I was wondering how I could upload mp3s using a form and php, because when I try it with the image form, it give me errors. Thanks.
Posted: Sun Mar 30, 2003 8:35 pm
by fractalvibes
uploading any kind of file should be pretty much the same, I would think.
What does your code look like? Are do doing image manipulation in the script?
Phil J.
Posted: Sun Mar 30, 2003 9:23 pm
by thoughtriot
Code: Select all
<?
include('../top.php');
echo "<p align=center><b>Add MP3</b><br>Be patient. This could take a while.</p>";
if($submit) {
copy($file, "/home/arsonfor/public_html/music/mp3s/$file_name");
$result=MYSQL_QUERY("INSERT INTO mp3s (ID,Title,URL,Album)".
"VALUES ('NULL', '$Title', '$file_name', '$Album')");
print "MP3 added";
}
else
{
?>
<form method="post" ENCTYPE="multipart/form-data" action="addmp3s.php">
Title:<br>
<INPUT TYPE='TEXT' NAME='Title' size=60><br>
Album:<br>
<select name='Album'>
<?
$result = mysql_query ("SELECT * FROM albums ORDER BY Title ASC");
while($r=mysql_fetch_array($result))
{
$ID = $r["ID"];
$Title = $r["Title"];
echo "<option value=$ID>$Title</option>";
}
?>
</select><br>
MP3:<br>
<input type="file" size="60" name="file"><br>
<INPUT TYPE="submit" name="submit" value="Submit">
</form>
<?
}
include('../bottom.php');
?>
It is supposed to upload the mp3 and then input the mp3 information into the database. It adds the title, id, album id, and url for the mp3 into the database, but it won't upload the mp3.