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

[eluser]rogierb[/eluser]
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?
#12

[eluser]123wesweat[/eluser]
hmmm,

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

and when i upload a jpg it returns
Code:
doc
docx
gif
jpeg

when i try to upload a .txt
Code:
doc
docx
gif
Array ( [error] =>

The filetype you are attempting to upload is not allowed.
)

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

Is there a particular order we should follow??
#13

[eluser]123wesweat[/eluser]
Ok this is strange

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

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

[eluser]rogierb[/eluser]
The order shouldn't matter.

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

[eluser]Craig300[/eluser]
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
#16

[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

Code:
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.
#17

[eluser]crojac[/eluser]
See my post on the subject

http://ellislab.com/forums/viewthread/146338/
#18

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

[eluser]Unknown[/eluser]
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.
#20

[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