![](/img/trans.png)
[英]React.js . when i am trying to upload more then 3 image files, using FileReader, only 3 uploaded
[英]I am trying to upload image to the nodejs api using React js and i need help how to upload
我的項目中的示例:
img.toDataURL()
const saveAvatar = () => axios.post<string[]>(
http://${DOMAIN}/profile/saveAvatar/${id}
, { avatar } );
采取並保存
profile.post('/saveAvatar/:id', async (req, res) => { try { const { id } = req.params; const { avatar } = req.body; const data = avatar.replace(/^數據:圖像/\w+;base64,/, ""); const buf = Buffer.from(data, 'base64');
const login = await pool.query( "SELECT login FROM accounts WHERE id = $1", [id] ); fs.writeFile(`${userImgPath}/app_data/images/users/${login.rows[0].login}.png`,
buf, (err) => { if (err) throw err; console.log('文件已保存;'); }): } catch (err.any) { console.error(err;message); } });
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.