简体   繁体   English

从后端文件夹获取图像并在前端显示(React 和 Node)

[英]Get image from Backend folder and display it in frontend (React and Node)

i have an upload method that store my image in a folder in backend.我有一个上传方法,可以将我的图像存储在后端的文件夹中。 I'm trying to display it in the frontend but it says to me that it can't accomplish my request becouse folder is out of src.我试图在前端显示它,但它告诉我它无法完成我的请求,因为文件夹不在 src 中。 How can i avoid this issue?我怎样才能避免这个问题?

Is there any kind of method that allow me to access to the path of that folder?有什么方法可以让我访问该文件夹的路径吗? I'm using react and node js.我正在使用反应和节点 js。

You have to serve static files with express, here explains how to do that.您必须使用 express 提供 static 文件,这里解释了如何做到这一点。

I hope that it works for you!我希望它对你有用!

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 将数据从Node后端传输到React前端 - Transfer data from Node backend to React frontend 将图像从反应前端上传到表达后端并在前端显示 - uploading image from react frontend to express backend and displaying it back in the frontend 如何从快速后端服务器获取图像并将其显示到 React js 前端? - How to Fetch and Display an Image from an express backend server to a React js frontend? 如何从快速后端服务器获取图像并将其显示到 React Native 前端? - How to Fetch and Display an Image from an express backend server to a React Native frontend? 将多个图像从后端(节点)发送到前端(反应) - sending multiple images from backend(node) to frontend(react) 如何使用 React 从后端数据库中获取以显示在前端? - How to fetch from backend database to display on frontend using react? 如何显示来自 express 后端的错误消息以响应前端? - How to display error message from express backend to react frontend? 如何从后端节点 js 获取 Json 数据到前端 html - How to get Json data from backend node js to frontend html ReactJS 无法使用 node.js 显示来自后端文件夹的图像 - ReactJS cannot display image from backend folder using node.js 无法通过我的前端从我的节点 js 服务器下载图像文件(我的后端和前端是解耦的) - Failed to download an image file from my node js server through my frontend (my backend and frontend are decoupled)
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM