It seems that this url cannot be inserted into the img tag
See original GitHub issuethis is the uploadImages code
uploadImages={async (files) => {
return await uploadImges(files);
}}
this is the my uplload and download code
export async function upload(files) {
let formData = new FormData();
formData.append("files[]", files);
let res = await axios.post("/file/upload", formData, {
headers: {
"Content-Type": "multipart/form-data",
},
});
if (res.data.stat === "ok") {
return res.data.data;
} else {
return null;
}
}
export async function download(key) {
let res = await axios.get(`/file/download/${key}`, {
responseType: "blob",
});
let blob = new Blob([res.data]);
return window.URL.createObjectURL(blob);
}
interface Pick {
alt: string;
title: string;
url: string;
}
export async function uploadImges(files) {
let imgs: Pick[] = [];
for (let file of files) {
let key = await upload(file);
let url = await download(key);
console.log(url);
let img: Pick = {
alt: "img",
title: "img",
url: url,
};
imgs.push(img);
}
return imgs;
}
because the sever code is fixed ,I can only use the method to upload image and download
As you can see, the src of the picture is empty
Maybe I used it wrong, please help me, I will be very grateful
Issue Analytics
- State:
- Created 2 years ago
- Comments:5 (3 by maintainers)
Top Results From Across the Web
HTML <img> tag is not working - Stack Overflow
Check that JPG file extension is uppercase in the file system. I suspect that it is lowercase. Also be sure to close the...
Read more >A 4-Minute Guide to the Img src Attribute in HTML
The source attribute contains the path to the image file or its URL. That explains why images are technically linked to — not...
Read more ><img>: The Image Embed element - HTML - MDN Web Docs
The HTML element embeds an image into the document. ... The src URL is the same as the URL of the page the...
Read more >How to handle loading of images that may not exist?
An image URL that is incorrect or points to an image that no longer exists, is most likely a data issue. So the...
Read more >you can't insert a site-local image URL · Issue #20903 - GitHub
I want to insert existing images on my web site, i.e. the img src attribute for them will be /path/to/image.jpg .
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
Thank you . Your suggestion is very useful, and I have gained a lot.