Welcome Guest, Not a member yet? Register   Sign In
CI mime types cause error with file upload
#1

[eluser]charlie spider[/eluser]
[ i accidently posted this in Bug Reports at first, so apoligies to anybody that sees this twice ]

i copied the mime types array from the APP/config/mimes.php file,
then stripped out some of the file types i didn’t want, ( a mime is a terrible thing to waste )
then used that to create my list of allowed file types for file uploading
Code:
$mimes = array(    
        'csv'    =>    array('text/x-comma-separated-values', 'text/comma-separated-values', 'application/octet-stream', 'application/vnd.ms-excel', 'text/csv', 'application/csv', 'application/excel', 'application/vnd.msexcel'),
        'psd'    =>    'application/x-photoshop',
        'pdf'    =>    array('application/pdf', 'application/x-download'),
        'ai'    =>    'application/postscript',
        'eps'    =>    'application/postscript',
        'ps'    =>    'application/postscript',
        'xls'    =>    array('application/excel', 'application/vnd.ms-excel'),
        'ppt'    =>    array('application/powerpoint', 'application/vnd.ms-powerpoint'),
        'gtar'    =>    'application/x-gtar',
        'gz'    =>    'application/x-gzip',
        'swf'    =>    'application/x-shockwave-flash',
        'tar'    =>    'application/x-tar',
        'tgz'    =>    'application/x-tar',
        'xhtml'    =>    'application/xhtml+xml',
        'xht'    =>    'application/xhtml+xml',
        'zip'    =>  array('application/x-zip', 'application/zip', 'application/x-zip-compressed'),
        'mid'    =>    'audio/midi',
        'midi'    =>    'audio/midi',
        'mpga'    =>    'audio/mpeg',
        'mp2'    =>    'audio/mpeg',
        'mp3'    =>    array('audio/mpeg', 'audio/mpg'),
        'aif'    =>    'audio/x-aiff',
        'aiff'    =>    'audio/x-aiff',
        'aifc'    =>    'audio/x-aiff',
        'ram'    =>    'audio/x-pn-realaudio',
        'rm'    =>    'audio/x-pn-realaudio',
        'rpm'    =>    'audio/x-pn-realaudio-plugin',
        'ra'    =>    'audio/x-realaudio',
        'rv'    =>    'video/vnd.rn-realvideo',
        'wav'    =>    'audio/x-wav',
        'bmp'    =>    'image/bmp',
        'gif'    =>    'image/gif',
        'jpeg'    =>    array('image/jpeg', 'image/pjpeg'),
        'jpg'    =>    array('image/jpeg', 'image/pjpeg'),
        'jpe'    =>    array('image/jpeg', 'image/pjpeg'),
        'png'    =>    array('image/png',  'image/x-png'),
        'tiff'    =>    'image/tiff',
        'tif'    =>    'image/tiff',
        'css'    =>    'text/css',
        'html'    =>    'text/html',
        'htm'    =>    'text/html',
        'shtml'    =>    'text/html',
        'txt'    =>    'text/plain',
        'text'    =>    'text/plain',
        'log'    =>    array('text/plain', 'text/x-log'),
        'rtx'    =>    'text/richtext',
        'rtf'    =>    'text/rtf',
        'xml'    =>    'text/xml',
        'xsl'    =>    'text/xml',
        'mpeg'    =>    'video/mpeg',
        'mpg'    =>    'video/mpeg',
        'mpe'    =>    'video/mpeg',
        'qt'    =>    'video/quicktime',
        'mov'    =>    'video/quicktime',
        'avi'    =>    'video/x-msvideo',
        'movie'    =>    'video/x-sgi-movie',
        'doc'    =>    'application/msword',
        'docx'    =>    'application/vnd.openxmlformats-officedocument.wordprocessingml.document',
        'xlsx'    =>    'application/vnd.openxmlformats-officedocument.spreadsheetml.sheet',
        'word'    =>    array('application/msword', 'application/octet-stream'),
        'xl'    =>    'application/excel',
        'eml'    =>    'message/rfc822'
);

$config['allowed_types'] = 'cpt'; // enter first element manually

foreach ( $mimes as $mime => $type )
{
    $config['allowed_types'] .= '|' . $mime; // add additional elements preceeded with a pipe
}


echoing the allowed_types produces this :

cpt|csv|psd|pdf|ai|eps|ps|xls|ppt|gtar|gz|swf|tar|tgz|xhtml|xht|zip|mid|midi|mpga|mp2|mp3|aif|aiff|aifc|ram|rm|rpm|ra|rv|wav|bmp|gif|jpeg|jpg|jpe|png|tiff|tif|css|html|htm|shtml|txt|text|log|rtx|rtf|xml|xsl|mpeg|mpg|mpe|qt|mov|avi|movie|doc|docx|xlsx|word|xl|eml

which looks ok to my (naive?) eye.


then, if i try to upload any kind of file (i’m using a txt file for testing purposes) i get:

The filetype you are attempting to upload is not allowed.

that’s in FF3, IE7, and Chrome


if i reduce the allowed types to simply:
Code:
$config['allowed_types'] = 'txt';
then it works fine, so i know the problem isn’t elsewhere.



Does anybody have any golden nuggets of wisdom and/or experience they can share that might help to solve this problem ?
Or has anybody else experienced one of the above mime types throwing the whole machine out of whack ?

Thanks in advance for any and all advice.


Messages In This Thread
CI mime types cause error with file upload - by El Forum - 07-28-2009, 01:07 PM
CI mime types cause error with file upload - by El Forum - 07-28-2009, 01:52 PM
CI mime types cause error with file upload - by El Forum - 08-01-2009, 08:32 AM
CI mime types cause error with file upload - by El Forum - 12-06-2009, 10:10 PM



Theme © iAndrew 2016 - Forum software by © MyBB