小编Sil*_*ter的帖子

expressjs:从父目录发送文件

我想使用expressjs的sendfile从脚本文件的父目录发送文件.我试图做的是这样的:

app.get('/', function(req, res){
    res.sendfile('../../index.html');
});
Run Code Online (Sandbox Code Playgroud)

我得到一个禁止的错误,因为很明显,sendfile不信任路径遍历.到目前为止,我一直无法弄清楚如何更改通过sendfile发送的文件的目录.任何提示?

编辑:发帖时我有点累,实际上它很容易.我会把它留在这里以防万一其他人偶然发现这件事.sendfile有一个选项参数,允许你这样做,如下所示:

app.get( '/', function( req, res ){
    res.sendfile('index.html', { root: "../../"});
});
Run Code Online (Sandbox Code Playgroud)

javascript sendfile express

7
推荐指数
1
解决办法
9465
查看次数

不能同时包含Eigen和boost/regex

我可以单独包含每个库,但是当我尝试同时包含它们时,我会遇到大量错误.我正在使用Boost v1_55_0和Eigen v3.2.1.知道问题可能是什么?

我的包括如下所示:

#include <boost/regex.hpp>
#include <Eigen>
Run Code Online (Sandbox Code Playgroud)

我正在粘贴下面的第一个错误,其中有超过100个.

Error   1   error C1189: #error :  The Eigen/Array header does no longer exist in Eigen3. All that functionality has moved to Eigen/Core.   c:\local\eigen\array    8   1   Project1
2   IntelliSense: #error directive: The Eigen/Array header does no longer exist in Eigen3. All that functionality has moved to Eigen/Core.  c:\local\Eigen\Array    8   4   Project1
3   IntelliSense: expected a declaration    c:\local\boost_1_55_0\boost\functional\hash\extensions.hpp  160 13  Project1
4   IntelliSense: expected a declaration    c:\local\boost_1_55_0\boost\functional\hash\extensions.hpp  162 5   Project1
5   IntelliSense: expected …
Run Code Online (Sandbox Code Playgroud)

c++ regex boost eigen

4
推荐指数
1
解决办法
1358
查看次数

标签 统计

boost ×1

c++ ×1

eigen ×1

express ×1

javascript ×1

regex ×1

sendfile ×1