Use gm to read the image, the path is correct,
Error report: gm convert unable to open file ...[NO such file or directory]
router.js
//path.join(__dirname,'../avatar/',filename)等价于 ==c:\users\MrsH\Desktop\codeth\shuoshuo\router\avatar\uestcw.jpg 所以路径是没有问题,图片存在可以无法读取并修改 gm(path.join(__dirname, '../avatar/', filename)) .crop(w,h,x,y) .resize(100,100,"!") .write(path.join(__dirname, './avatar/', filename),function(err){ if(err){ console.log(err) res.send("-1"); return; } res.send("1"); });
The following is the document tree
So when path.join is used in the future, it means that files in the current directory should not be added
./