From 19391a089e7beb092298c708ac39237cce80e474 Mon Sep 17 00:00:00 2001 From: Naz Date: Tue, 3 Feb 2026 15:08:11 +0800 Subject: [PATCH] update upload image --- .../InventoryReportManagement.cshtml | 2 +- Controllers/API/Inventory/InvMainAPI.cs | 24 ++++++++++++++----- 2 files changed, 19 insertions(+), 7 deletions(-) diff --git a/Areas/Report/Views/Reporting/InventoryReportManagement.cshtml b/Areas/Report/Views/Reporting/InventoryReportManagement.cshtml index a8574f0..bbaa9cb 100644 --- a/Areas/Report/Views/Reporting/InventoryReportManagement.cshtml +++ b/Areas/Report/Views/Reporting/InventoryReportManagement.cshtml @@ -84,7 +84,7 @@
-
Total Items Registered
+
Total Products Registered

{{ reportData.itemCountRegistered }}

diff --git a/Controllers/API/Inventory/InvMainAPI.cs b/Controllers/API/Inventory/InvMainAPI.cs index f50b736..875eeff 100644 --- a/Controllers/API/Inventory/InvMainAPI.cs +++ b/Controllers/API/Inventory/InvMainAPI.cs @@ -1358,16 +1358,28 @@ namespace PSTW_CentralSystem.Controllers.API.Inventory } private bool IsImage(byte[] bytes) { - // JPEG file signature: FF D8 FF - if (bytes.Length > 2 && bytes[0] == 0xFF && bytes[1] == 0xD8 && bytes[2] == 0xFF) + if (bytes.Length < 4) return false; + + // JPEG: Starts with FF D8 + if (bytes[0] == 0xFF && bytes[1] == 0xD8) return true; - // PNG file signature: 89 50 4E 47 0D 0A 1A 0A - if (bytes.Length > 7 && bytes[0] == 0x89 && bytes[1] == 0x50 && bytes[2] == 0x4E && bytes[3] == 0x47) + // PNG: 89 50 4E 47 + if (bytes[0] == 0x89 && bytes[1] == 0x50 && bytes[2] == 0x4E && bytes[3] == 0x47) return true; - // GIF file signature: GIF87a or GIF89a - if (bytes.Length > 5 && bytes[0] == 0x47 && bytes[1] == 0x49 && bytes[2] == 0x46) + // GIF: GIF8 + if (bytes[0] == 0x47 && bytes[1] == 0x49 && bytes[2] == 0x46) + return true; + + // WebP: Starts with 'RIFF' and has 'WEBP' at offset 8 + if (bytes.Length > 12 && + bytes[0] == 0x52 && bytes[1] == 0x49 && bytes[2] == 0x46 && bytes[3] == 0x46 && // RIFF + bytes[8] == 0x57 && bytes[9] == 0x45 && bytes[10] == 0x42 && bytes[11] == 0x50) // WEBP + return true; + + // HEIC (iPhone): Look for 'ftypheic' or 'ftypmif1' + if (bytes.Length > 12 && bytes[4] == 0x66 && bytes[5] == 0x74 && bytes[6] == 0x79 && bytes[7] == 0x70) return true; return false;