Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/node.js/38.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
Node.js 只打电话。错误:查找视图失败";“错误”;在视图目录中_Node.js_Ionic2 - Fatal编程技术网

Node.js 只打电话。错误:查找视图失败";“错误”;在视图目录中

Node.js 只打电话。错误:查找视图失败";“错误”;在视图目录中,node.js,ionic2,Node.js,Ionic2,大家好,我知道这个问题存在好几次,但我查看了所有问题,但找不到任何解决方案。我有一个ionic应用程序,可以运行所有功能,但只有更改配置文件图片帖子在服务器上给出了该错误 客户端 ChangeTheProfilePicture() { this.camera.getPicture(this.options).then((imageData) => { this.imageURL = 'data:image/jpeg;base64,' + imageData; var data =

大家好,我知道这个问题存在好几次,但我查看了所有问题,但找不到任何解决方案。我有一个ionic应用程序,可以运行所有功能,但只有更改配置文件图片帖子在服务器上给出了该错误

客户端

ChangeTheProfilePicture() {
this.camera.getPicture(this.options).then((imageData) => {

  this.imageURL = 'data:image/jpeg;base64,' + imageData;
  var data = {
    img: this.imageURL
  }
  this.http.post('http://myIpAdress:3100/api/addProfilePic', data)
    .subscribe((data1: any) => {
      console.log("done: ", data1);
    }, err => {
      console.log("photo err: ", err);
    })
})}
服务器

  app.use(function (req, res, next) {
  res.header("Access-Control-Allow-Origin", "*");
  res.header('Access-Control-Allow-Methods', 'GET,PUT,POST,DELETE,OPTIONS');
  res.header("Access-Control-Allow-Headers", "X-Requested-With,Content-
  Type,Cache-Control");
  if (req.method === 'OPTIONS') {
    res.statusCode = 204;

    return res.end();
  }
  else {
    return next();
  }
  });
app.use(function (req, res, next) {
var err = new Error('Not Found');
err.status = 404;
next();
});

// error handlers

if (app.get('env') === 'development') {
app.use(function (err, req, res, next) {
    res.status(err.status || 500);
    res.render('error', {
        message: err.message,
        error: err
    });
});
}

//View Engine
app.set('views', path.join(__dirname, 'views'));
app.set('view engine', 'ejs');
app.engine('html', require('ejs').renderFile);


//set static folder
app.use(express.static(path.join(__dirname, 'client')));
当我在手机上拍照,然后按OK按钮时,服务器端会出现错误(它甚至无法通过路由获取postapi/addProfilePic)。我猜我的客户端为true,但服务器端的setting views文件夹是错误的

文件根目录

ChangeTheProfilePicture() {
this.camera.getPicture(this.options).then((imageData) => {

  this.imageURL = 'data:image/jpeg;base64,' + imageData;
  var data = {
    img: this.imageURL
  }
  this.http.post('http://myIpAdress:3100/api/addProfilePic', data)
    .subscribe((data1: any) => {
      console.log("done: ", data1);
    }, err => {
      console.log("photo err: ", err);
    })
})}


谢谢

我发现,图像太大,无法发布,我将使用ionic文件传输。

出现什么错误?错误:无法在视图目录中查找视图“错误”