React Dropzone:图像文件预览问题

发布于 2025-02-09 17:36:20 字数 327 浏览 2 评论 0 原文

我在React Dropzone中上传图像文件。但是,上传后,该文件已成功上传(我可以在控制台中看到它),但是有时会预览图像文件,有时相同的图像文件给出了错误:

get blob:http:// http:// localhost:3000/438716d3 -2317-438b-9d1e-eb7bc5e6149f net :: err_file_not_found

I upload image file with previewing it in react dropzone. However, after uploading, the file is successfully uploaded (I can see it in console) but sometimes the image file is previewed and sometimes the same image file give error like:

GET blob:http://localhost:3000/438716d3-2317-438b-9d1e-eb7bc5e6149f net::ERR_FILE_NOT_FOUND

https://i.sstatic.net/AwjI9.png

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

哆啦不做梦 2025-02-16 17:36:20

我遇到了这个问题,解决方案是在显示dropzone的图像文件时在图像SRC中使用url.createobjecturl。
例如,

<img src={URL.createObjectURL(file)} alt={file.name} />

希望这对别人有帮助。

I had this issue and the solution was to use URL.createObjectURL in the image src when displaying the image file from Dropzone.
e.g

<img src={URL.createObjectURL(file)} alt={file.name} />

Hopefully this helps someone else.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文