Press Ctrl / CMD + C to copy this to your clipboard.
This post will be reported to the moderators as potential spam to be looked at
I've created a custom forms workflow to save submissions for a particular form to an external database. One of the columns in that database is a user icon in Base64 string format. I followed the steps to create the workflow type and all non-images fields save correctly. The problem is the image file upload field. When I get the value for the icon image field (using context.Record.GetRecordFieldByAlias("myalias")) I see that it's the media path "/media/forms/upload/form_227751f3-6756-401a-a5af-ec7c458fae1f/8451990e-d83c-4aef-819e-8bacee1933f5/chickadee.png". How do I get that media item using that path so that I can save the icon image to the external database?
I got too deep into trying to do this through umbraco utilities that I missed the easy solution right in front of me. I have the relative URI of the image which is stored in wwwroot so I was able to use that to do regular file I/O and convert that image to base64.
can you share your code here?
Below is the function I use to process the images from the form, where path is context.Record.GetRecordFieldByAlias("imageAlias").ValuesAsString().
// from https://devblogs.microsoft.com/dotnet/net-core-image-processing/
public string ResizeAndSaveFormFileImage(string path)
string wwwrootPath = _environment.WebRootPath;
string fullPath = Path.Combine(wwwrootPath, path);
Uri uri = new Uri(wwwrootPath + path);
string test = uri.AbsolutePath;
int maxWidth = 800;
int maxHeight = 600;
Image image = Image.FromFile(test);
int width, height;
// only resize if the image is too large
if (image.Width >= maxWidth || image.Height > maxHeight)
if (image.Width > image.Height)
width = maxWidth;
height = Convert.ToInt32(image.Height * maxWidth / (double)image.Width);
width = Convert.ToInt32(image.Width * maxHeight / (double)image.Height);
height = maxHeight;
width = image.Width;
height = image.Height;
var resized = new Bitmap(image, width, height);
string base64String = string.Empty;
using (MemoryStream memoryStream = new())
var bytes = new byte[memoryStream.Length - 1];
memoryStream.Position = 0;
memoryStream.Read(bytes, 0, bytes.Length);
base64String = Convert.ToBase64String(bytes, 0, bytes.Length);
is working on a reply...
Write your reply to:
Image will be uploaded when post is submitted