From 4194831f02e0dc0e15865c92bfd9a2f5aacdf812 Mon Sep 17 00:00:00 2001 From: Brady Miller Date: Sat, 22 Oct 2022 13:22:32 -0700 Subject: [PATCH] bug fix 1 --- controllers/C_Document.class.php | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) diff --git a/controllers/C_Document.class.php b/controllers/C_Document.class.php index 5eb1b7217..3fd3ce106 100644 --- a/controllers/C_Document.class.php +++ b/controllers/C_Document.class.php @@ -274,7 +274,6 @@ class C_Document extends Controller } $za->close(); if ($mimetype == "application/dicom+zip") { - $_FILES['file']['type'][$key] = $mimetype; sleep(1); // Timing insurance in case of re-compression. Only acted on index so...! $_FILES['file']['size'][$key] = filesize($_FILES['file']['tmp_name'][$key]); // file may have grown. } @@ -293,8 +292,7 @@ class C_Document extends Controller if ($_POST['destination'] != '') { $fname = $_POST['destination']; } - // set mime, test for single DICOM and assign extension if missing. - $mimetype = $_FILES['file']['type'][$key]; + // test for single DICOM and assign extension if missing. if (strpos($filetext, 'DICM') !== false) { $mimetype = 'application/dicom'; $parts = pathinfo($fname); @@ -302,6 +300,15 @@ class C_Document extends Controller $fname .= '.dcm'; } } + // set mimetype (if not already set above) + if (empty($mimetype)) { + $mimetype = mime_content_type($_FILES['file']['tmp_name'][$key]); + } + // if mimetype still empty, then do not upload the file + if (empty($mimetype)) { + $error = xl("Unable to discover mimetype, so did not upload " . $_FILES['file']['tmp_name'][$key]) . ".\n"; + continue; + } $d = new Document(); $rc = $d->createDocument( $patient_id, -- 2.11.4.GIT