nodejs读取图片返回给浏览器显示
求地址,转换成实际的文件地址。判断文件是否存在,不存在返回404,存在则读取文件 ,并返回文件。//设置请求的返回头type,content的type类型列表见上面response.setHeader("Content-Type", contentType);//格式必须为 binary 否则会出错var content = fs.readFileSync(url,"binary");response.writeHead(200, "Ok");response.write(content,"binary"); //格式必须为 binary,否则会出错response.end();二、动态文件