Jump to content

Recommended Posts

Posted

I encountered this problem when I did my own upload PHP scripts.

I can upload any file types to my hosting using FTP or filemanager, including mp3,

but with the upload scripts I've made, I can upload any files types, from .swf, .wmv to even .exe

BUT NOT .MP3..

It's very very weird to encounter this problem, hope someone can tell me what's wrong,

or maybe server configuration problem??

 

Million thanks to those who tried to help.

Posted

I've 2 source code, one is simple code with no file type restriction

<?php

 

$target_path = "upload/";

 

$target_path = $target_path . basename( $_FILES['uploadedfile']['name']);

 

if(move_uploaded_file($_FILES['uploadedfile']['tmp_name'], $target_path)) {

echo "The file ". basename( $_FILES['uploadedfile']['name']).

" has been uploaded";

} else{

echo "There was an error uploading the file, please try again!";

}

 

?>

 

I quoted only the PHP part, HTML part I think is not necessary..

While another PHP script, is rather complicated.. I only quoted the file type part as follow

$allowed_types = array("image/gif", "image/jpeg", "image/x-png", "image/bmp", "audio/mp3");

which is nothing wrong also...

 

My guess would be server configuration problem..

 

Can we have a look at the source code?

 

I've just modified the mime type in cPanel,

by adding audio/mp3, .mp3 extension into mime..

but upload still show invalid file type...

someone please help me...

Posted

I have no clue what the problem is. It's probably function-specific - check the PHP manual.

Posted

LOL even djbob also had no idea.

anyway, I don't really think is function problem,

since I can never do any file limitation on my PHP script,

all types of files should can be uploaded right?

somemore, I can upload wma, wmv, exe, pdf, blahblahblah...

just not mp3....

the biggest joke I've ever met!

Posted

Erm... another problem here.

I have Apache 2.2, PHP 5.2.4, MySQL 5.0.27, with phpmyadmin 2.11.5

I tried on my localhost, I can upload .mp3 file successfully.

With same scripts, I can't upload .mp3, as mentioned before, I can upload all other file types.

 

Really hope someone can offer me a help. Thanks!

Posted

As I said, I have no clue why this is happening. It is probably something having to do with the upload libraries your scripts use. Find a forum or support site dealing with those and ask them if they know anything. If they say you need root or shell access, post the URL here and I will take a look at what the fix requires.

  • 2 years later...
Posted

Sorry for bringing up the dead post.

Does it work with the other, more complicated script?

MP3's MIME type is not audio/mp3 , it's audio/mpeg . Does that help?

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...