错误:ENOENT:没有此类文件或目录,请取消链接

编程入门 行业动态 更新时间:2024-10-27 15:27:56
本文介绍了错误:ENOENT:没有此类文件或目录,请取消链接的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述

如您所见,路径中有一个文件.但是fs说没有这样的文件或目录.我不明白为什么?

As you can see, there is a file at the path. But fs says no such file or directory. I can't understand why?

在另一个文件中,我可以使用相同的代码删除.

In another file, I can remove with the same code.

我的boat.js文件:

My boat.js file:

boat.findById(req.params.id,function(err, foundBoat) { if(err){ console.log(err); }else{ foundBoat.boatsFoto.forEach(function(path){ console.log(typeof(path)); fs.unlink("../public"+path,function(err){ if(err) throw err; console.log('File deleted!'); }); }); } });

这是我的错误:

Error: ENOENT: no such file or directory, unlink '../public/uploads/akingokay/BoatsFoto/1524411110335kiralik-tekne.jpg' at Error (native)

您可以看到我的文件系统

推荐答案

您可以尝试以下方法吗?

Can you try this instead:

fs.unlink("public"+path,function(err){ if(err) throw err; console.log('File deleted!'); });

更多推荐

错误:ENOENT:没有此类文件或目录,请取消链接

本文发布于:2023-07-04 11:12:06,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1023639.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:此类   错误   链接   文件   目录

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!