Skip to main content
format code blocks
Source Link
ggorlen
  • 59.3k
  • 8
  • 119
  • 173

I have this code
var express = require('express'); var http = require('http');

var express = require('express'); var http = require('http'); var app = express(); var server = http.createServer(app); app.use(express.static(__dirname + '/uploads')); console.log("listen to 8080"); server.listen(8080); 

I have my image in /uploads/test.jpg but/uploads/test.jpg but when I go to http://localhost:8080/uploads/test.jpg ihttp://localhost:8080/uploads/test.jpg I get Cannot GET /uploads/testCannot GET /uploads/test.jpg.jpg

I have this code
var express = require('express'); var http = require('http');

var app = express(); var server = http.createServer(app); app.use(express.static(__dirname + '/uploads')); console.log("listen to 8080"); server.listen(8080); 

I have my image in /uploads/test.jpg but when I go to http://localhost:8080/uploads/test.jpg i get Cannot GET /uploads/test.jpg

I have this code

var express = require('express'); var http = require('http'); var app = express(); var server = http.createServer(app); app.use(express.static(__dirname + '/uploads')); console.log("listen to 8080"); server.listen(8080); 

I have my image in /uploads/test.jpg but when I go to http://localhost:8080/uploads/test.jpg I get Cannot GET /uploads/test.jpg.

Source Link
user3631341
  • 525
  • 2
  • 5
  • 16

How to serve images in nodejs express

I have this code
var express = require('express'); var http = require('http');

var app = express(); var server = http.createServer(app); app.use(express.static(__dirname + '/uploads')); console.log("listen to 8080"); server.listen(8080); 

I have my image in /uploads/test.jpg but when I go to http://localhost:8080/uploads/test.jpg i get Cannot GET /uploads/test.jpg