( I'm going to add in security when I actually get the damn file onto the server )
heres the upload form:
<table width="500" border="0" align="center" cellpadding="0" cellspacing="1" bgcolor="#CCCCCC"> <tr> <form action="mp3upload.php" method="post" enctype="multipart/form-data"> <td> <table width="100%" border="0" cellpadding="3" cellspacing="1" bgcolor="#FFFFFF"> <tr> <td colspan="2"><div align="center"><strong>Upload Music to Mp3 Player </strong></div></td> </tr> <tr> <td>Genre of Music</td> <td><select name="genre"> <option value="rock">Rock/Metal</option> <option value="rap">Rap</option> <option value="techno">Techno</option> <option value="trance">Trance</option> <option value="habibi">Habibi</option> <option value="misc">Misc.</option> </select></td> </tr> <tr> <td> Select MP3</td> <td><input name="file" type="file" /></td> </tr> <tr> <td colspan="2" align="center"><input type="submit" name="submit" value="Upload" /></td> </tr> </table> </td> </form> </tr> </table>
heres the actual php script:
<?php
if($_POST['submit']) {
/*
$rock = "mp3s/rock/";
$rap = "mp3s/rap/";
$techno = "mp3s/techno/";
$habibi = "mp3s/habibi/";
$trance = "mp3s/trance/";
$misc = "mp3s/misc/";
*/
if ($_POST['genre'] == "rock"){
copy($HTTP_POST_FILES['file']['tmp_name'],"/mp3s/rock/".$HTTP_POST_FILES['file']['name']);
unlink($HTTP_POST_FILES['file']['tmp_name']);
echo ' <h1> Thanks for uploading! </h1> ';
}else if ($_POST['genre'] == "rap"){
copy($HTTP_POST_FILES['file']['tmp_name'],"/mp3s/rap/".$HTTP_POST_FILES['file']['name']);
unlink($HTTP_POST_FILES['file']['tmp_name']);
echo ' <h1> Thanks for uploading! </h1> ';
}else if ($_POST['genre'] == "techno"){
copy($HTTP_POST_FILES['file']['tmp_name'],"/mp3s/techno/".$HTTP_POST_FILES['file']['name']);
unlink($HTTP_POST_FILES['file']['tmp_name']);
echo ' <h1> Thanks for uploading! </h1> ';
}else if ($_POST['genre'] == "trance"){
copy($HTTP_POST_FILES['file']['tmp_name'],"/mp3s/trance/".$HTTP_POST_FILES['file']['name']);
unlink($HTTP_POST_FILES['file']['tmp_name']);
echo ' <h1> Thanks for uploading! </h1> ';
}else if ($_POST['genre'] == "habibi"){
copy($HTTP_POST_FILES['file']['tmp_name'],"/mp3s/habibi/".$HTTP_POST_FILES['file']['name']);
unlink($HTTP_POST_FILES['file']['tmp_name']);
echo ' <h1> Thanks for uploading! </h1> ';
}else if ($_POST['genre'] == "misc"){
copy($HTTP_POST_FILES['file']['tmp_name'],"/mp3s/misc/".$HTTP_POST_FILES['file']['name']);
unlink($HTTP_POST_FILES['file']['tmp_name']);
echo ' <h1> Thanks for uploading! </h1> ';
}else
echo ' <h1><font color="red"><strong>UPLOAD FAILED!</strong></font></h1> ';
}
?>
any help appreciated
edit: the folders have read/write access
Edited by HiJinks, 23 March 2007 - 01:32 AM.
