I wrote a code in php to upload mp3 files but it is not working. It uploads other file exrtensions but does not upload mp3 files. If I remove "if($_FILES=="audio/mp3"" then files is uploaded in database but not in the subfolder "upload". Can any one help me. I'll be thankful.

if($ftype=="audio/mp3")
{
if($songtype=="Pakistani Songs")
{
	$sql="SELECT songname FROM songs WHERE songname='$fname'";
	$result=mysql_query($sql);
    $num=mysql_num_rows($result);
	if($num>0&&(file_exists("upload/".$fname)))  { 
	?>
	<script type="text/javascript">
	window.location.href="uploadform.php?flag=1";
	</script>
	<?php }
	else {
    $query="INSERT INTO songs (songname,singername,maname,songtype,filetype,filesize,uploaddate) VALUES ('$fname','$singer','$manameup','$songtype','$ftype','$fsize',NOW())"; 
	mysql_query($query);  ?>
	<div align="center"><p2><?="File Uploaded Sucessfully"?></p2><br><a href="uploadform.php">Back</a></div>
	 <?php 
               
               move_uploaded_file($_FILES['audio']['tmp_name'],"upload/".$fname); 
	 } 
}
}

maybe the type is audio/mpeg or application/octet-stream

you've got to try with different browsers to see how each one of them is sending the content.

another option is to check the first 2-3 bytes of the uploaded file if it is "ID3"
I checked a few mp3s I have and they start with ID3

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.