Hey guys, I am getting an error while uploading files on web3Storage. here’s the error:-Error uploading file: Error: missing input file(s). And code is mentioned below.
async function storeDriveFiles(){
console.log(document.getElementById("input").files[0]);
var fileInput = document.getElementById("input");
const rootCid = await client.put(fileInput.files[0]);
console.log(rootCid);
const res = await client.get(rootCid);
const files = await res.files();
const url = URL.createObjectURL(files[0]);
setFile(url);
}
const fileEvent = async(e) => {
const data = e.target.files;
try {
if (
data[0].type == "application/pdf" ||
data[0].type == "application/json" ||
data[0].type == "image/png" ||
data[0].type == "image/jpg" ||
data[0].type == "image/jpeg" ||
data[0].type == "text/plain" ||
data[0].type == "text/csv"
) {
await storeDriveFiles(data[0]);
} else {
console.log("Please upload pdf, json, txt, csv, png, jpg or jpeg!");
}
} catch (error) {
console.log("Error uploading file: ", error);
}
}
Thank you.