Hi,
This script works great when uploading photos but if I try mp3's I get 'Error uploading file'
Any ideas would be much appreciated!
Thanks
<?
$uploadDir = 'mp3/';
include ("../includes/database.connect.php");
if(isset($_POST['send']))
{
$fileName = $_FILES['userfile']['name'];
$tmpName = $_FILES['userfile']['tmp_name'];
$fileSize = $_FILES['userfile']['size'];
$fileType = $_FILES['userfile']['type'];
// get the file extension first
$ext = substr(strrchr($fileName, "."), 1);
// generate the random file name
$randName = md5(rand() * time());
// and now we have the unique file name for the upload file
$filePath = $uploadDir . $randName . '.' . $ext;
$result = move_uploaded_file($tmpName, $filePath);
if (!$result) {
echo "Error uploading file";
exit;
}
if(!get_magic_quotes_gpc())
{
$fileName = addslashes($fileName);
$filePath = addslashes($filePath);
}
$query = "INSERT INTO show_archive (file ) ".
"VALUES ('$filePath')";
mysql_query($query) or die('Error, query failed : ' . mysql_error());
echo "<br>File uploaded<br>";
}
?>
<form action="" method="post" enctype="multipart/form-data" name="uploadform">
<table width="350" border="0" cellpadding="1" cellspacing="1" class="box">
<tr>
<td width="246"><input type="hidden"><input name="userfile" type="file" class="box" id="userfile">
</td>
</tr>
<td align="center" valign="middle" colspan="2"><input class="button" type="submit" name="send" value="Submit Details" tabindex="80" /> <a href="index.php" class="box_link3">Back to List</a></form></td>
</table>
</form>