trying to convert a pdf object a user uploads via form to a base64string
public async Task<IActionResult> AddDocument([Bind("formFile")]File file)
{
byte[] a = System.IO.File.ReadAllBytes(file);
string s = Convert.ToBase64String(a);
...
}
my file input is as such:
<input class="form-control" type="file" id="formFile" style="display:block" name="formFile">
however i am getting this error message:
cannot convert from System.IO.FileInfo to string
is it not possible to convert a pdf to a base64string?
According to what I made in my project, I'd do the following:
In my case, I actually have several file uploads, but that's easy to manage.