mirror of
https://github.com/Part-DB/Part-DB-server.git
synced 2025-06-21 09:35:49 +02:00
Use the same behavior to determine the extension of file attachments like PartKeepr does, to ensure that all attachments are shown as available
This fixes issue #291
This commit is contained in:
parent
8bb8257e62
commit
35490762a6
1 changed files with 9 additions and 1 deletions
|
@ -84,7 +84,15 @@ trait PKImportHelperTrait
|
||||||
|
|
||||||
//Determine file extension (if the extension is empty, we use the original extension)
|
//Determine file extension (if the extension is empty, we use the original extension)
|
||||||
if (empty($attachment_row['extension'])) {
|
if (empty($attachment_row['extension'])) {
|
||||||
$attachment_row['extension'] = pathinfo($attachment_row['originalname'], PATHINFO_EXTENSION);
|
//Use mime type to determine the extension like PartKeepr does in legacy implementation (just use the second part of the mime type)
|
||||||
|
//See UploadedFile.php:291 in PartKeepr (https://github.com/partkeepr/PartKeepr/blob/f6176c3354b24fa39ac8bc4328ee0df91de3d5b6/src/PartKeepr/UploadedFileBundle/Entity/UploadedFile.php#L291)
|
||||||
|
if (empty ($attachment_row['mimetype'])) {
|
||||||
|
$attachment_row['extension'] = explode('/', $attachment_row['mimetype'])[1];
|
||||||
|
} else {
|
||||||
|
//If the mime type is empty, we use the original extension
|
||||||
|
$attachment_row['extension'] = pathinfo($attachment_row['originalname'], PATHINFO_EXTENSION);
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
//Determine file path
|
//Determine file path
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue