Warning: file_get_contents(/data/phpspider/zhask/data//catemap/3/reactjs/25.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Reactjs 为什么可以';部署MERN堆栈项目时是否上载映像?_Reactjs_Mongodb_Express_Mongoose - Fatal编程技术网

Reactjs 为什么可以';部署MERN堆栈项目时是否上载映像?

Reactjs 为什么可以';部署MERN堆栈项目时是否上载映像?,reactjs,mongodb,express,mongoose,Reactjs,Mongodb,Express,Mongoose,在本地连接到服务器并尝试上载映像时,效果良好,但在heroku上部署项目并尝试上载映像时,他会发送以下错误: 2021-04-11T05:45:01.411678+00:00 app[web.1]: [Error: ENOENT: no such file or directory, open './public/img/photo_1618119901407.jpg'] { 2021-04-11T05:45:01.411680+00:00 app[web.1]: errno: -2, 20

在本地连接到服务器并尝试上载映像时,效果良好,但在heroku上部署项目并尝试上载映像时,他会发送以下错误:

2021-04-11T05:45:01.411678+00:00 app[web.1]: [Error: ENOENT: no such file or directory, open './public/img/photo_1618119901407.jpg'] {
2021-04-11T05:45:01.411680+00:00 app[web.1]:   errno: -2,
2021-04-11T05:45:01.411680+00:00 app[web.1]:   code: 'ENOENT',
2021-04-11T05:45:01.411681+00:00 app[web.1]:   syscall: 'open',
2021-04-11T05:45:01.411681+00:00 app[web.1]:   path: './public/img/photo_1618119901407.jpg'
2021-04-11T05:45:01.411682+00:00 app[web.1]: }
2021-04-11T05:45:01.411986+00:00 app[web.1]: 500 
controller/post.js:

let file = req.files.image;
file.name = `photo_${Date.now()}${path.parse(file.name).ext}`;
file.mv(`${process.env.FILE_UPLOAD_PATH}${file.name}`, async err => {

    if (err) {
        console.log(err)
        return next(500, `problem with file upload`)
    }

    // save new post in db
    req.body.imageUrl = file.name;
    result = await postSchema.create({
        title: req.body.title,
        content: req.body.content,
        imageUrl: req.body.imageUrl,
        creator: {
            id: req.user.id,
            name: req.user.name
        },
    })
})