我正在尝试将包含多个图像的对象作为数组发布,如何将图像作为数组附加到 formdata
const onSubmit = async (e) => {
const formData = new FormData();
formData.append("image", values.images);
formData.append("title", values.title);
formData.append("price", values.price);
formData.append("quantity", values.quantity);
formData.append("id", id);
try {
const res = await axios.post(
"//localhost:4000/products/saveProduct",
formData,
{
headers: {
"Content-Type": "multipart/form-data",
},
/////////////
<form onSubmit={handleSubmit(onSubmit)}>
<div className="custom-file mb-4">
<input
type="file"
className="custom-file-input"
name="image"
multiple
placeholder="choose file"
onChange={handleChange}
/>
//////
const handleChange = (e) => {
const { type, name } = e.target;
const getValue = () => {
if (type === "checkbox") {
return …Run Code Online (Sandbox Code Playgroud) 我已经建立了一个网站,当我在主页上刷新时,它很好,但是当我导航到其他页面时,它也很好,但是当我刷新这些其他页面时
\nCannot GET /otherpage\nRun Code Online (Sandbox Code Playgroud)\n我正在使用反应导航,如果我超链接它,我认为它可能也不起作用。
\n\n\xef\xbb\xbfrequire('rootpath')();\nconst express = require('express');\nconst app = express();\n///\n///\napp.use('/accounts', require('./accounts/accounts.controller'));\n\nif(process.env.NODE_ENV === 'production'){\n \n app.use(express.static('build'));\n\n \n\n }\nRun Code Online (Sandbox Code Playgroud)\nserver.js\nbuild\nRun Code Online (Sandbox Code Playgroud)\n文件目录
\n我该如何解决这个问题?
\n