Welcome Guest, Not a member yet? Register   Sign In
Upload File Bug
#1

[eluser]adamp1[/eluser]
I have a form which I can upload both jpg's and pdf's. So I pass a filetype string of jpg|pdf into the upload library.

Now when I try and upload a PDF it says incorrect filetype. On looking at the upload class I know why but I don't understand why it has been changed from version 1.6.3, this never seems like it will work.

In is_allowed_filetype()
Code:
$image_types = array('gif', 'jpg', 'jpeg', 'png', 'jpe');

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;
                }    
            }        
        }

So assume I have uploaded a PDF, and $val = 'jpeg', well it will go into the 'extra image check' and enter it (since $val is in $image_types), and then return FALSE, since it won't be able to get the imagesize since the file is a pdf.

I believe changing the following lines corrects the issue:
Code:
// Images get some additional checks
if (in_array($this->file_ext, $image_types))


Messages In This Thread
Upload File Bug - by El Forum - 04-29-2009, 01:00 PM
Upload File Bug - by El Forum - 05-05-2009, 09:30 AM
Upload File Bug - by El Forum - 05-05-2009, 09:34 AM
Upload File Bug - by El Forum - 05-07-2009, 08:45 AM
Upload File Bug - by El Forum - 05-07-2009, 09:08 AM
Upload File Bug - by El Forum - 05-07-2009, 04:03 PM
Upload File Bug - by El Forum - 05-20-2009, 12:08 AM
Upload File Bug - by El Forum - 05-20-2009, 08:42 AM
Upload File Bug - by El Forum - 05-20-2009, 09:21 PM
Upload File Bug - by El Forum - 05-20-2009, 09:56 PM
Upload File Bug - by El Forum - 05-20-2009, 10:20 PM
Upload File Bug - by El Forum - 05-20-2009, 10:31 PM
Upload File Bug - by El Forum - 05-20-2009, 10:59 PM
Upload File Bug - by El Forum - 05-20-2009, 11:40 PM
Upload File Bug - by El Forum - 05-21-2009, 12:44 AM
Upload File Bug - by El Forum - 05-21-2009, 01:10 AM
Upload File Bug - by El Forum - 05-21-2009, 05:01 AM
Upload File Bug - by El Forum - 05-21-2009, 06:15 AM
Upload File Bug - by El Forum - 06-10-2009, 09:22 PM
Upload File Bug - by El Forum - 06-11-2009, 12:38 AM
Upload File Bug - by El Forum - 06-17-2009, 11:16 AM
Upload File Bug - by El Forum - 06-18-2009, 09:25 AM
Upload File Bug - by El Forum - 06-29-2009, 12:00 AM
Upload File Bug - by El Forum - 06-29-2009, 12:03 AM
Upload File Bug - by El Forum - 07-13-2009, 07:40 PM
Upload File Bug - by El Forum - 08-28-2009, 01:56 AM
Upload File Bug - by El Forum - 08-28-2009, 09:32 AM
Upload File Bug - by El Forum - 09-04-2009, 08:00 PM
Upload File Bug - by El Forum - 09-29-2009, 02:28 AM
Upload File Bug - by El Forum - 09-29-2009, 02:38 PM
Upload File Bug - by El Forum - 10-01-2009, 01:05 AM
Upload File Bug - by El Forum - 10-01-2009, 01:12 AM
Upload File Bug - by El Forum - 10-22-2009, 01:13 PM
Upload File Bug - by El Forum - 07-11-2011, 02:46 AM



Theme © iAndrew 2016 - Forum software by © MyBB