A
Size: a a a
A
AS
A
A
P
АП
E
if (req.url === "/upload") {
req.on("data", function (chunk) {
let part = chunk.toString();
let fileName = /(?<=filename=").+(?=")/.exec(part)[0];
let file = fs.createWriteStream("./src/uploads/" + fileName);
const rs = new Readable();
rs._read = () => {
if (chunk) {
rs.push(chunk)
}
rs.push(null);
};
rs.pipe(file);
file.on("finish", () => console.log("Done"));
});
req.on("end", function () {
res.statusCode = 200;
res.write("<h1>File uploading was done</h1>");
res.end();
});
AS
MV
AS
MV
AS
MV
MV
ОК
ОК
MV