CodeIgniter Forums

Full Version: Uploading a .rtf file
You're currently viewing a stripped down version of our content. View the full version with proper formatting.

El Forum

Hello, I have following problem. I need to upload .rtf files to the server. This is my upload form:

echo form_open_multipart('/text/add',$form_params);
<?php echo form_upload('userfile');?>

and my text/add is following:

$config['upload_path'] = './texts';
$config['allowed_types'] = 'rtf|doc|docx';
$this->load->library('upload', $config);

And when i'm uploading .doc file, that's ok - but when it's .rtf, directory ./texts is empty.

I also added the
'rtf'   =>  'application/rtf'
to mime array in config/mimes.php.

What's wrong?

El Forum


El Forum

From what I've noticed is that depending on the browser you can get different mime types for the same type of file extension - I don't know the specifics, only that I've noticed it.

To fix upload mime issues you can use the upload classes data function to print out the mime type of the file you're attempting to upload.

echo '<pre>';

Out of this you'll see the file_type index which is the mime type of the rtf file in the browser you're using.

Once you know you're mime type add it to you're config/mimes.php file. My rtf mime extensions for one of my applications is this:
'rtf'   =>      array('application/msword', 'text/rtf')