MP3 upload problem

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
Addos
Forum Contributor
Posts: 305
Joined: Mon Jan 17, 2005 4:13 pm

MP3 upload problem

Post by Addos »

Code: Select all

if ($_FILES['fupload']['type'] == "audio/mpeg")
I'm using the above script to upload mp3 files to a folder but I'm getting
the error that it's the wrong file type. I have access to set permissions
myself and the file path is

Code: Select all

$target = "../../audio/mp3/" 
.$_FILES['fupload']['name'];
Any ideas as to why this is? I have set permissions on both folders where
the file is to be sent.

Thanks
User avatar
pickle
Briney Mod
Posts: 6445
Joined: Mon Jan 19, 2004 6:11 pm
Location: 53.01N x 112.48W
Contact:

Re: MP3 upload problem

Post by pickle »

Your "above" script is just an if condition & does absolutely nothing with moving or uploading files. Some relevant code would be appreciated :?
Real programmers don't comment their code. If it was hard to write, it should be hard to understand.
Addos
Forum Contributor
Posts: 305
Joined: Mon Jan 17, 2005 4:13 pm

Re: MP3 upload problem

Post by Addos »

Okay here is all the code.
thanks
Last edited by Addos on Tue Aug 12, 2008 2:06 pm, edited 1 time in total.
User avatar
pickle
Briney Mod
Posts: 6445
Joined: Mon Jan 19, 2004 6:11 pm
Location: 53.01N x 112.48W
Contact:

Re: MP3 upload problem

Post by pickle »

Echo $_FILES['fupload']['type'] & see what your files are being uploaded as. It's likely you've just got the wrong mime type in there.
Real programmers don't comment their code. If it was hard to write, it should be hard to understand.
Addos
Forum Contributor
Posts: 305
Joined: Mon Jan 17, 2005 4:13 pm

Re: MP3 upload problem

Post by Addos »

Thanks for the help.
I have output the following and get

Code: Select all

<?PHP echo $_FILES['fupload']['type'];?> // audio/x-mpeg
<? echo $_FILES['fupload']['name'];?> // song.mp3  
I have searched the net but can't see any other MIME type other than audio/mpeg

Also if I use image/jpeg I can upload this fine so I'm fairly sure that the conditional statements and file paths/permissions are okay.

Any ideas why I can't upload this mp3?
Thanks
User avatar
pickle
Briney Mod
Posts: 6445
Joined: Mon Jan 19, 2004 6:11 pm
Location: 53.01N x 112.48W
Contact:

Re: MP3 upload problem

Post by pickle »

pickle wrote:It's likely you've just got the wrong mime type in there.
Look closer at what the mime type actually is, and what you're checking for.
Real programmers don't comment their code. If it was hard to write, it should be hard to understand.
Addos
Forum Contributor
Posts: 305
Joined: Mon Jan 17, 2005 4:13 pm

Re: MP3 upload problem

Post by Addos »

"Look closer at what the mime type actually is, and what you're checking for"
thanks for the reply but I'm really not sure how to look closer at what type of mime is as I thought I was checking taht it was a mp3 by using audio/mpeg.
Is there any other script that I can use to output more info on the file I'm trying to upload. I know it's definately an mp3 so any pointers would be great.
thanks :wink:
User avatar
pickle
Briney Mod
Posts: 6445
Joined: Mon Jan 19, 2004 6:11 pm
Location: 53.01N x 112.48W
Contact:

Re: MP3 upload problem

Post by pickle »

The type you're checking for: audio/mpeg.
The type of the mp3: audio/x-mpeg
Real programmers don't comment their code. If it was hard to write, it should be hard to understand.
Post Reply