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

[eluser]peekk[/eluser]
Hello, I have following problem. I need to upload .rtf files to the server. This is my upload form:

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

and my text/add is following:

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

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

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

What's wrong?

El Forum

[eluser]peekk[/eluser]
anyone?

El Forum

[eluser]fuchong[/eluser]
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.

Code:
echo '<pre>';
var_dump($this->upload->data());

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:
Code:
'rtf'   =>      array('application/msword', 'text/rtf')