I am using A FileInput component to upload files;
- I cannot bind (or, get in any way) the filename
- If I try to specify that I want to bind the value to a byte[], it does not work. Only a string is acceptable
I am using A FileInput component to upload files;
Hi @gounaras,
Not sure I understand the issue. FileInput component works with base64 encoded strings only. FileName and FileSize properties were just added:
Here is the component demo:
Never mind ...
Just updated to the latest and it works (@bind-FileName)
The issue was the same as the article you reference.
Thanks
Hi,
Try this. It works for me.
<RadzenFormField>
<ChildContent>
<RadzenFileInput @bind-FileName=@fileName @bind-FileSize=@fileSize TValue="string" class="w-100"
Change=@(args => OnChange(args, fileName)) Error=@(args => OnError(args, fileName)) />
</ChildContent>
</RadzenFormField>
@code
{
public string fileName;
long? fileSize;
static string base64EncodedImageData;
void OnChange(string value, string name)
{
fileName = $"{name}";
// Convert Base64 String to byte[]
string[] dbInfo = value.Split("base64,");
base64EncodedImageData = dbInfo[1].ToString();
byte[] imageBytes = Convert.FromBase64String(base64EncodedImageData);
application.Photo = imageBytes;
application.Image = name;
}
void OnError(UploadErrorEventArgs args, string name)
{
string err = $"{args.Message}";
}
}