【文件属性】:
文件名称:node-image-upload:关于如何使用 Node.js 上传图像的教程
文件大小:38KB
文件格式:ZIP
更新时间:2021-07-11 04:27:36
JavaScript
#图片上传
使用纯 Node.js 创建图像上传非常广泛,因为您需要手动解析POST body ,检查文件类型等,为了让我们的生活更轻松,我们将使用formidable ,这很方便。对于这些情况.
##强大
模块是专门用于解析表单数据的,让我们进入正题。
我们创建了一个 http 服务器来测试我们的上传路由:
var formidable = require('formidable')
, http = require('http')
, fs = require('fs')
;
http.createServer(function(req, res){
if(!((req.url === "/upload") && (req.method === "POST"))){
home(res);
}else{
upload(req, res);
【文件预览】:
node-image-upload-master
----.gitignore(34B)
----express()
--------routes()
--------views()
--------bin()
--------public()
--------app.js(1KB)
--------package.json(359B)
----README.md(8KB)
----upload-formidable.js(2KB)
----package.json(851B)