我有文件上传API,该API会在文件上传时发送SUCCESS消息,而在未选择文件时会发送FAILURE消息。
app.js
name
代替res.send(),我想显示一些在我的html代码上定义的模式框。在我发帖请求时,需要有关如何合并或显示此模式框的帮助。
index.html
const express = require("express");
const app = express();
const http = require("http").Server(app).listen(3000);
const upload = require("express-fileupload");
const request = require("request");
app.use(express.urlencoded());
app.use(express.json());
app.use(upload({
useTempFiles: true,
tempFileDir: '/tmp/'
}));
console.log("Server Started");
// To load both HTML and CSS files on the root call
app.use(express.static(__dirname + "/public"));
app.get("/", function (req, res) {
res.sendFile(__dirname + "/index.html");
}
)
app.post("/", function (req, res) {
if (req.files.filename.name) {
res.send("uploaded");
}
else
res.send("Please select the file to upload!");
})