I have a form with multiple inputs, one being of type="file". Where I want to be able to upload an image and then post the form to the api so it's stored on the database.
<input name="image" class="w-full border-2 border-gray-200 rounded-3xl px-4 py-4" type="file" placeholder="Event Image" />
However when I enter all the form values (including file uploading and image) I get this error:
"error TypeError: Failed to execute 'append' on 'FormData': parameter 2 is not of type 'Blob'."
I'm pushing the values into formdata which is then posted to the API
...
methods: {
async onSubmit(values) {
console.log("button submitted")
try {
var formdata = new FormData();
formdata.append("name", values.eventname);
formdata.append("description", values.eventdescription);
formdata.append("image", values.image, "Image");
...
How can I convert the file type to blob so it can be uploaded? Thank you