Welcome Guest, Not a member yet? Register   Sign In
Upload filetype not allowed??

Yeah, it looks okay, but is doesnt work... So either $this->mimes_types is off or some other random error.

Can you debug is_allowed_filetype()?
See why it is returning a FALSE?


in Upload.php in function is_allowed_filetype() i added
foreach ($this->allowed_types as $val)
            echo $val;

and when i upload a jpg it returns

when i try to upload a .txt
Array ( [error] =>

The filetype you are attempting to upload is not allowed.

Now the strange thing is when i use
$config['allowed_types'] = 'txt|text';
it does upload the .txt file.

Is there a particular order we should follow??

Ok this is strange

this seems to be a working array
$config['allowed_types'] = 'doc|docx|pdf|txt|text|rtf|jpg|gif';

not working
$config['allowed_types'] = 'doc|docx|gif|jpeg|pdf|jpg|rtf|txt|text';

The order shouldn't matter.

Can you debug set_allowed_types() to see what $types and $this->allowed_types are?

I had a similar problem and found that if I put the pdf file extension at the beginning of that list, it seemed to work.

Eg: pdf|doc|docx etc

[eluser]Vangelis B[/eluser]
[quote author="rogierb" date="1266418911"]The order shouldn't matter.

Can you debug set_allowed_types() to see what $types and $this->allowed_types are?[/quote]

Unfortunately the people are right. The order does matter. The reason is that the upload library first does a check for images before check in the config/mimes.php. The library checks to see if the temp file (during the upload) returns an image size. Unfortunately it does the check for files that are not images as well. Obviously this is a bug.

A temporary solution is to comment the following lines in system/libraries/upload.php

if (in_array($val, $image_types)){
  if (getimagesize($this->file_temp) === FALSE){
    return FALSE;

they are around line 565

I'll submit this bug and lets hope that CI devs will come up with a fix in the next CI version.

See my post on the subject


[eluser]Phil Sturgeon[/eluser]
This has been fixed in CodeIgniter 2.0.

As far as RTF goes, this can be a tricky mime-type to deal with. In general, the mime-type for RTF is 'application/rtf' and NOT 'text/rtf' (according to w3schools and good ol' M$). So right off the hop, Codeigniter has a possibly incorrect mime-type listed.

HOWEVER, some products stamp the mime-type as 'application/msword' for RTF files. We had to change the 'rtf' entry in the mimetypes array (located in /system/application/config/mimes.php) to be 'application/msword' to get our users' RTF files uploading correctly. This may have something to do with the way the RTF file type is defined on their Windows XP computers, I am not 100% certain.

WHEN IN DOUBT, install the Live HTTP Headers Add-On in Firefox, it will let you know what the browser is thinking in terms of what the file type is that is being uploaded.

[eluser]Ossama Khayat[/eluser]
I suffered trying to fix this, and after some debugging I found the solution, which is what in the patch for 2.0.
Why isn't this also fixed for 1.7.2?

Theme © iAndrew 2016 - Forum software by © MyBB