0

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); 
	 } 
}
}
2
Contributors
1
Reply
2
Views
6 Years
Discussion Span
Last Post by lordspace
0

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

This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.