nodejs - 브 라 우 저 에서 기본적으로 열 린 파일 을 다운로드 로 변환 합 니 다.

731 단어 nodejs
var express=require("express")
var app=express();
var fs = require('fs');
var path=require("path");
app.get("/upload",function(req,res){
    var filePath = path.join(__dirname, './');
    console.log(filePath)
    fs.readFile(filePath+"images/2010191.png", function(err, data){
        res.set({
            'Content-Type': 'application/octet-stream',  //              
            'Content-Disposition': 'attachment; filename=upload.png'  //               png  
        });
        res.end(data)
    })
    


})
app.listen(3000,function(){
    console.log("server is running")
})

좋은 웹페이지 즐겨찾기