How can a server built by express directly splice url on a browser to access static resources such as pictures?

  node.js, question
If you use serve-static, if you use it incorrectly, you will not get the result. What is the general idea?
 var constants = require('./constants/event');
 var utils = require('util');
 var path = require('path')
 var fs = require('fs')
 var querystring = require('querystring');
 var formidable = require('formidable')
 var bodyParser = require('body-parser');
 var express = require('express')();
 var app = require('http').createServer(express);
 var io = require('socket.io').listen(app);
 var url = require('url');
 var User = require('./model/user');
 var _ = require('underscore');
 var mongoose = require('mongoose');
 var port = 3030;
 
 mongoose.connect("mongodb://localhost/imchat");
 
 express.use(bodyParser.json())
 express.use(bodyParser.urlencoded({extended:true}))
 express.use(require('express').static(path.join(__dirname,"upload")))

In this way, the picture is placed under the upload folder, and the whole project structure is very simple.图片描述
There are so many main codes, followed by some route mapping processing. I don’t know what the problem is.

There may be a problem with the address of the static directory.
Example: runningnode example.jsfrom/Users/mjr

console.log(__dirname);
 // /Users/mjr

Try changing it to this and see if it works.

express.use(require('express').static(path.join(__dirname,"/upload")))