Codeigniter 3 send file with PFX extension

0

I need to upload a file with the extension .pfx (digital certificate).

I'm using library Upload of CodeIgniter as follows: I'm putting the allowed_types extension, but it does not send. Return: The type of file you are trying to upload is not allowed.

$config['upload_path'] = $pasta;
$config['allowed_types'] = 'pfx';
$config['max_size'] = 100000;
$config['encrypt_name'] = TRUE;

$this - > load - > library('upload');
$this - > upload - > initialize($config);
if ($this - > upload - > do_upload('userfile')) {
    echo json_encode(array('image1' = > $this - > upload - > data('file_name'), 'file_ext' = > str_replace(".", "", $this - > upload - > data('file_ext')), 'error' = > 0, 'mensage' = > 'Arquivo enviado com sucesso.'));
} else {
    echo json_encode(array('mensage' = > $this - > upload - > display_errors(), 'error' = > 1));
}
    
asked by anonymous 05.01.2017 / 18:11

2 answers

2

This error occurs because the framework is not finding this extension in the mime types list, that is, it does not know what it is or how to handle a .pfx file. To solve, open config/mimes.php of your application and add the following line to the end of array() :

'pfx' => array('application/octet-stream'),

Source: Preferences ; get_mimes () ; Mime type of pfx .

    
06.01.2017 / 13:45
0

In addition to updating your MIMES files, also use the header type application / x-pkcs12,

That is:

'pfx'   =>  array('application/octet-stream', 'application/x-pkcs12')
    
24.07.2017 / 15:59