I want to display a blob image, but i get this error :
here is my js part of the code :
const etat = $('#etat').html();
const photoDiv = $('.photoDiv');
if(etat === 'true'){
const url = $('#url').text();
console.log(url);
const img = document.createElement("img");
img.src = url;
img.height = 200;
img.width = 200;
img.onload = () => {
URL.revokeObjectURL(img.src);
}
photoDiv.append(img);
}
url is the blob url that i get after processing some tasks in the backend with createObjectURL, this is why i used revokeObjectURL after
does anynone know where this error comes from ? also i'm using a blob url i didn't use an absolute local path for img.src like it can be said on other posts ...
Here is my backend code (deno) :
const uploadFiles = async(ctx:any)=>{
const body = await ctx.request.body({type: 'form-data'});
const product = await body.value.read({maxSize: 500000000 });
if(!ctx.request.hasBody){
ctx.response.status = 400;
ctx.response.body ={
success: false,
msg: 'No data'
}
}else{
try {
const file =product.files[0].content;
const blob = new Blob([file],{type: 'image/jpeg'});
console.log('blob : ' + blob)
const url = URL.createObjectURL(blob);
console.log('url : ' + url);
ctx.render('./fu.ejs',{upload:true, urlData: url});
} catch (err) {
ctx.response.status = 200;
ctx.response.body = {
success: false,
msg: err.toString()
}
}finally{
}
}
}
export {uploadFiles};
console :
simply, in one hand i want to store an image in my database in a certain format and on the other hand i want to display this image on my webpage from this database, this is why i tried to bring the input file to my backend code