Compare commits

..

2 Commits

Author SHA1 Message Date
osaajani c2ead276dc fix version 2021-02-23 14:39:59 +01:00
osaajani cafe210f69 Fix bad mimetype when importing csv from a windows computer 2021-02-23 14:30:39 +01:00
3 changed files with 16 additions and 3 deletions

View File

@ -1 +1 @@
v3.0.8 v3.0.10

View File

@ -214,6 +214,7 @@ namespace controllers\internals;
'content' => 'Une erreur inconnue est survenue.', 'content' => 'Une erreur inconnue est survenue.',
'error_code' => $file['error'] ?? 99, 'error_code' => $file['error'] ?? 99,
'mime_type' => false, 'mime_type' => false,
'extension' => false,
]; ];
if (UPLOAD_ERR_OK !== $file['error']) if (UPLOAD_ERR_OK !== $file['error'])
@ -265,7 +266,8 @@ namespace controllers\internals;
return $result; return $result;
} }
$result['mime_type'] = 'text/plain' === mime_content_type($tmp_filename) ? $file['type'] : mime_content_type($tmp_filename); $result['extension'] = pathinfo($file['name'])['extension'];
$result['mime_type'] = mime_content_type($tmp_filename);
$file_handler = fopen($tmp_filename, 'r'); $file_handler = fopen($tmp_filename, 'r');
$result['success'] = true; $result['success'] = true;

View File

@ -302,7 +302,18 @@ namespace controllers\publics;
break; break;
default: default:
$invalid_type = true; if ($read_file['extension'] === 'csv')
{
$result = $this->internal_contact->import_csv($id_user, $read_file['content']);
}
elseif ($read_file['extension'] === 'json')
{
$result = $this->internal_contact->import_json($id_user, $read_file['content']);
}
else
{
$invalid_type = true;
}
} }
if ($invalid_type) if ($invalid_type)