Welcome Guest, Not a member yet? Register   Sign In
Upload any file - what's a framework really for?
#6

[eluser]Colin Williams[/eluser]
This is a dead-easy implementation.

application/libraries/MY_Upload.php

Code:
class MY_Upload {

        // --------------------------------------------------------------------
    
    /**
     * Verify that the filetype is allowed
     *
     * @access    public
     * @return    bool
     */    
    function is_allowed_filetype()
    {
        if (count($this->allowed_types) == 0 || ! is_array($this->allowed_types))
        {
            // Return TRUE instead of failing. I would recommend a more concrete way of allowing all file types
            return TRUE;
        }
                
        foreach ($this->allowed_types as $val)
        {
            $mime = $this->mimes_types(strtolower($val));
        
            if (is_array($mime))
            {
                if (in_array($this->file_type, $mime, TRUE))
                {
                    return TRUE;
                }
            }
            else
            {
                if ($mime == $this->file_type)
                {
                    return TRUE;
                }    
            }        
        }
        
        return FALSE;
    }
}


Messages In This Thread
Upload any file - what's a framework really for? - by El Forum - 08-17-2008, 09:05 PM
Upload any file - what's a framework really for? - by El Forum - 08-17-2008, 10:10 PM
Upload any file - what's a framework really for? - by El Forum - 08-17-2008, 10:20 PM
Upload any file - what's a framework really for? - by El Forum - 08-17-2008, 10:20 PM
Upload any file - what's a framework really for? - by El Forum - 08-17-2008, 10:21 PM
Upload any file - what's a framework really for? - by El Forum - 08-17-2008, 11:37 PM
Upload any file - what's a framework really for? - by El Forum - 08-18-2008, 12:34 AM
Upload any file - what's a framework really for? - by El Forum - 08-18-2008, 12:48 PM
Upload any file - what's a framework really for? - by El Forum - 08-18-2008, 12:53 PM
Upload any file - what's a framework really for? - by El Forum - 08-18-2008, 01:06 PM
Upload any file - what's a framework really for? - by El Forum - 08-18-2008, 09:58 PM
Upload any file - what's a framework really for? - by El Forum - 08-19-2008, 10:44 AM



Theme © iAndrew 2016 - Forum software by © MyBB