express js error : “express deprecated res.sendfile: Use res.sendFile instead”

后端 未结 3 1975
情书的邮戳
情书的邮戳 2021-02-18 15:35

What is the right way to set path?

in my app i this code for i use set path for sending file.

app.get(\'/\',function(req, res){//get,put,post,delete   
          


        
3条回答
  •  佛祖请我去吃肉
    2021-02-18 16:16

    Considering this working example:

    router.get('/iso', (req, res) => {
        res.sendfile('public/isofinder.html');
    });
    

    This is not so easily translated into the method call sendFile.

    router.get('/iso', (req, res) => {
        res.sendFile(__dirname + '/../public/isofinder.html');
    });
    

    This variation gives a 403 error (Forbidden). In this case only this solution will work:

    router.get('/iso', (req, res) => {
        res.sendFile('[absolute_path_to_source]/public/isofinder.html');
    });
    

提交回复
热议问题