Jump to content

File type restrictions


JcX

Recommended Posts

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.

Link to comment
Share on other sites

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...

Link to comment
Share on other sites

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!

Link to comment
Share on other sites

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!

Link to comment
Share on other sites

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.

Link to comment
Share on other sites

  • 2 years later...

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...