Welcome Guest, Not a member yet? Register   Sign In
Do not define the data type to "upload"
#1

[eluser]Unknown[/eluser]
I want to use the library (upload) to upload files
but I will not define the type of file:

$config['allowed_types'] = '';
If I put it and tells me that: The filetype you Are
Attempting to upload is not allowed.

//$config['allowed_types'] = '';
Now if I remove that line I said: You have not
specified Any file types allowed.

Any suggestions? I do not want to define the type
of data to upload.

Thanks!
#2

[eluser]Eric Barnes[/eluser]
Currently you can do that by hacking the core. This feature is a part of the new reactor which you can get from bitbucket:
https://bitbucket.org/ellislab/codeignit...r/overview

From the change log:
Added a wildcard option $config['allowed_types'] = '*' to the File Uploading Class.
#3

[eluser]Cristian Gilè[/eluser]
Hi erikrocha,

this is a new feature in CI2 but, in the mean time, you can extends the upload class with this function:

Code:
public function is_allowed_filetype($ignore_mime = FALSE)
    {
        if ($this->allowed_types == '*')
        {
            return TRUE;
        }

        if (count($this->allowed_types) == 0 OR ! is_array($this->allowed_types))
        {
            $this->set_error('upload_no_file_types');
            return FALSE;
        }

        $ext = strtolower(ltrim($this->file_ext, '.'));

        if ( ! in_array($ext, $this->allowed_types))
        {
            return FALSE;
        }

        // Images get some additional checks
        $image_types = array('gif', 'jpg', 'jpeg', 'png', 'jpe');

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

        if ($ignore_mime === TRUE)
        {
            return TRUE;
        }

        $mime = $this->mimes_types($ext);

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

        return FALSE;
    }

then set the allowed_types setting to

Code:
$config['allowed_types'] = '*';

Cristian Gilè




Theme © iAndrew 2016 - Forum software by © MyBB