EllisLab text mark
Advanced Search
     
CI 2.1.2 - Unable to upload XML…
Posted: 09 November 2012 11:47 AM   [ Ignore ]
Joined: 2012-07-20
27 posts

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?

 
Posted: 09 November 2012 12:43 PM   [ Ignore ]   [ # 1 ]   [ Rating: 0 ]
Avatar
Joined: 2012-01-09
117 posts

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');
finfo_close($finfo);

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

// Method 3:
var_dump(mime_content_type('/path/to/your/file.xml')); 
 
Posted: 15 November 2012 05:35 PM   [ Ignore ]   [ # 2 ]   [ Rating: 0 ]
Joined: 2012-01-13
21 posts

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?

 
Posted: 15 November 2012 07:53 PM   [ Ignore ]   [ # 3 ]   [ Rating: 0 ]
Avatar
Joined: 2012-01-09
117 posts

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.