Welcome Guest, Not a member yet? Register   Sign In
file type to upload problem?
#1

[eluser]newbie boy[/eluser]
I have this "The file type you are attempting to upload is not allowed." problem...

whenener i upload a .wmv file

my config is this one...

Code:
$config['allowed_types'] = 'mpg|wmv|mov|flv|wma|mp4|avi';

but still the error displays...

hope you can help me guys...

thanks...
#2

[eluser]Jameson.[/eluser]
You will have to add an element to $mimes array in
system/application/config/mimes.php file:
'wmv' => 'video/x-ms-wmv'

You can look up all the MIMES for windows media files here - MIME Type Settings for Windows Media Services
#3

[eluser]newbie boy[/eluser]
done that but still doesn't work...
#4

[eluser]Jameson.[/eluser]
Your browser may be reporting another MIME for a .wmv file. Try to install LiveHTTPHeaders and look for the exact MIME you browser's sending while uploading.
#5

[eluser]Kow[/eluser]
Hi,
I had the same problem and I debugged it succesfully: it's a bug in: {root}/system/libaries/Upload.php on line: 557

Change to this:
Code:
// Images get some additional checks
if (in_array( $this->file_type, $image_types))
#6

[eluser]charlie spider[/eluser]
Thanks for catching that Kow. solved it for me.

it was line 567 in my Upload.php library, CI version 1.7.1, but i may have hacked the file before, don't remember.
#7

[eluser]wyred[/eluser]
Just experienced this problem and spent the whole morning debugging.

I can confirm that it's on line 567 as I have never touched the CI library files. I'm on version 1.7.1 too.
#8

[eluser]captainredmuff[/eluser]
Ok,

So you're suggesting that we change the following:

Code:
foreach ($this->allowed_types as $val)
        {
            $mime = $this->mimes_types(strtolower($val));

            // Images get some additional checks
            if (in_array($val, $image_types))
            {
                if (getimagesize($this->file_temp) === FALSE)
                {
                    return FALSE;
                }
            }

            if (is_array($mime))
            {
                if (in_array($this->file_type, $mime, TRUE))
                {
                    return TRUE;
                }
            }
            else
            {
                if ($mime == $this->file_type)
                {
                    return TRUE;
                }    
            }        
        }

to this:

Code:
foreach ($this->allowed_types as $val)
        {
            $mime = $this->mimes_types(strtolower($val));

            // Images get some additional checks
            if (in_array( $this->file_type, $image_types))
            {
                if (getimagesize($this->file_temp) === FALSE)
                {
                    return FALSE;
                }
            }

            if (is_array($mime))
            {
                if (in_array($this->file_type, $mime, TRUE))
                {
                    return TRUE;
                }
            }
            else
            {
                if ($mime == $this->file_type)
                {
                    return TRUE;
                }    
            }        
        }

This seems completely pointless, regardless of wether or not this fixes the problem.

Why loop through an array of allowed file types to not actually use any values at all. Surely this would just return true on the first iteration of the loop. Why not simply overload the function to just:

Code:
function is_allowed_filetype()
{
return true;
}

I appreciate that you probably spent a while locating this issue and managed to resolve it, but that fix just isn't correct in any shape or form.
#9

[eluser]dine[/eluser]
very effective!!

Can you please advice me about file type like doc,docx,rtf,pdf,odt.
I am getting same error like "File type not allowed"

http://ellislab.com/forums/viewthread/127863/

if I removed code line
$Uploadconfig[‘allowed_types’] = ‘doc|rtf|docx|pdf|odt’;

it gives error like you have not mentioned allowed type.

and If i make it blank like
$Uploadconfig[‘allowed_types’] = ‘’;

kindly help.




Theme © iAndrew 2016 - Forum software by © MyBB