Skip to content
Snippets Groups Projects
Commit ac42e624 authored by Jared Hancock's avatar Jared Hancock
Browse files

Inspect file mime type if not provided

parent efd0f5ae
No related branches found
No related tags found
No related merge requests found
......@@ -252,6 +252,20 @@ class AttachmentFile {
if(!$file['size'])
$file['size'] = strlen($file['data']);
if (!$file['type']) {
$finfo = new finfo(FILEINFO_MIME_TYPE);
if ($file['data'])
$type = $finfo->buffer($file['data']);
elseif ($file['tmp_name'])
$type = $finfo->file($file['tmp_name']);
if ($type)
$file['type'] = $type;
else
$file['type'] = 'application/octet-stream';
}
$sql='INSERT INTO '.FILE_TABLE.' SET created=NOW() '
.',type='.db_input(strtolower($file['type']))
.',size='.db_input($file['size'])
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment