Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Can I upload .c or .cpp file using CodeIgniter?

I want to upload a .c file. I am using CodeIgniter. The code I am using is working for .pdf but whenever I try to upload a .c file it shows "The filetype you are attempting to upload is not allowed.".

My code is given below:

$config = array
(
    'upload_path' => './solutions',
    'allowed_types' => 'c',
    'file_name' => $file_name,
    'file_size' => 1000,
    'remove_spaces' => 'true'
);
$this->upload->initialize($config);

When I write pdf in allowed types, it works, but not in the case of C.

like image 910
odbhut.shei.chhele Avatar asked Jun 22 '26 01:06

odbhut.shei.chhele


1 Answers

In allowed_types you need to have MIME types.

For a c source file that would be "text/plain", since there is no "c" MIME type.

See http://en.wikipedia.org/wiki/Internet_media_type

like image 192
pedrosorio Avatar answered Jun 23 '26 19:06

pedrosorio



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!