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
Addos
Forum Contributor
Posts: 305 Joined: Mon Jan 17, 2005 4:13 pm
Post
by Addos » Thu Jun 19, 2008 7:47 am
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
pickle
Briney Mod
Posts: 6445 Joined: Mon Jan 19, 2004 6:11 pm
Location: 53.01N x 112.48W
Contact:
Post
by pickle » Thu Jun 19, 2008 9:41 am
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
Post
by Addos » Thu Jun 19, 2008 10:30 am
Okay here is all the code.
thanks
Last edited by
Addos on Tue Aug 12, 2008 2:06 pm, edited 1 time in total.
pickle
Briney Mod
Posts: 6445 Joined: Mon Jan 19, 2004 6:11 pm
Location: 53.01N x 112.48W
Contact:
Post
by pickle » Thu Jun 19, 2008 11:13 am
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
Post
by Addos » Sun Jun 22, 2008 10:49 am
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
pickle
Briney Mod
Posts: 6445 Joined: Mon Jan 19, 2004 6:11 pm
Location: 53.01N x 112.48W
Contact:
Post
by pickle » Mon Jun 23, 2008 9:48 am
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
Post
by Addos » Mon Jun 23, 2008 10:03 am
"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
pickle
Briney Mod
Posts: 6445 Joined: Mon Jan 19, 2004 6:11 pm
Location: 53.01N x 112.48W
Contact:
Post
by pickle » Mon Jun 23, 2008 10:25 am
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.