Hi @Manyoni, Sandile, (Mr) (s220521409)
According to your code, you want to store images via base64.
Submit an image via a form on the View page:
<form action="/Home/Uploading" method="post" enctype="multipart/form-data">
<input type="file" name="imageFile" accept="image/*" />
<input type="submit" value="submit" />
</form>
Reads a byte array of picture files
byte[] imageBytes = new byte[imageFile.ContentLength];
imageFile.InputStream.Read(imageBytes, 0, imageFile.ContentLength);
Converts a byte array to a base64 string
string Base64ProfilePic = Convert.ToBase64String(imageBytes);
This gets your Base64ProfilePic. Then you can manipulate it through the database.
When you want to display the image, you can do so as follows.
<img src="data:image/png;base64,"+Base64ProfilePic alt="Image" />
If you have problems with the database and authentication, please continue to leave me a message. I will continue to help you solve the problem.
Best regards,
Qi You
If the answer is the right solution, please click "Accept Answer" and kindly upvote it. If you have extra questions about this answer, please click "Comment".
Note: Please follow the steps in our documentation to enable e-mail notifications if you want to receive the related email notification for this thread.