CodeIgniter Forums
Uploading a .rtf file - Printable Version

+- CodeIgniter Forums (https://forum.codeigniter.com)
+-- Forum: Archived Discussions (https://forum.codeigniter.com/forumdisplay.php?fid=20)
+--- Forum: Archived Development & Programming (https://forum.codeigniter.com/forumdisplay.php?fid=23)
+--- Thread: Uploading a .rtf file (/showthread.php?tid=50159)



Uploading a .rtf file - El Forum - 03-16-2012

[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?



Uploading a .rtf file - El Forum - 03-16-2012

[eluser]peekk[/eluser]
anyone?


Uploading a .rtf file - El Forum - 03-16-2012

[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')