Post Views: 253
แนะนำวิธีการแปลงรูปภาพ เป็น base64 เพื่อเก็บข้อมูล มีขั้นตอนดังนี้
1) สร้าง Project ผ่าน Visual Studio 2019 เลือก Blazor Server App
2) เลือก Framework เป็น .NET 5.0
3) ติดตั้ง Add-on ชื่อ System.Drawing.Common ผ่านทาง NuGet

4) เปิดไฟล์ Index.razor จากนั้นเขียน Code ดังนี้

5) หน้าจอแสดงปุ่ม “การแปลง (ไฟล์รูปภาพ เป็น Base64)”

6) ผลลัพธ์จากการแปลงไฟล์รูปภาพ เป็น Base64

หมายเหตุ: นามสกุลไฟล์รูปภาพ (picture.png) ต้องตรงกับ data:image/png;base64 สำหรับแสดงผล