Welcome Guest, Not a member yet? Register   Sign In
CI 2.1.2 - Unable to upload XML...

Hello all,

I'm on 2.1.2 and started to implement a file upload of an XML file type. This type is in the mimes file. The error received is always:

The filetype you are attempting to upload is not allowed.

even though I have set it as the allowed file type:

$config['upload_path'] = './uploads/';
$config['allowed_types'] = 'xml';
$config['max_size'] = '100';
$config['encrypt_name'] = TRUE;
$this->load->library( 'upload', $config );

In searching the forums here I see some older posts mentioning a bug in CI but it seems like 2.1.2 should have this corrected. If I set the file types to * then of course the upload works.

Is this still a problem or is there some other issue going on?

The most recent ones of the mentioned topics would probably have comments saying that MIME-type detection depends on the server environment and it is not 100% guaranteed to be correct - that's just not possible to achieve. What you can do is to check what each of these methods say the type is and add it to config/mimes.php:

//Method 1:
$finfo = finfo_open(FINFO_MIME);
var_dump(finfo_file($finfo, '/path/to/your/file.xml');

// Method 2:
file --mime /path/to/your/file.xml // (run in shell command line, on your host)

// Method 3:

Both those php functions are not supported on my host, and I do not have shell access,

I put the ogg file on the server and viewed it with my browser, shouldn't the http headers have the mime type assigned by the server?

You could then probably try to execute the file binary via PHP's exec(), shell_exec(), popen() - that's what CI does.
Otherwise yes, headers sent by the server should reflect what the type is according to the host.

Theme © iAndrew 2016 - Forum software by © MyBB