Comments (7)
router.post('/upload', async (ctx){
const file = ctx.request.body.files.file; // 获取上传文件
return ctx.body = file.path; // upload/xxx.xx
})
# 上面代码中ctx.request.body是空对象,文件信息还是放在ctx.request.files.file里
router.post('/upload', async (ctx){
const file = ctx.request.files.file; // 获取上传文件
return ctx.body = file.path; // upload/xxx.xx
})
The files property has been moved to ctx.request.files. In prior versions, files was a property of ctx.request.body
from blog.
线上博客用的是hexo theme还是自己写的
from blog.
@julyL 基于 hexo 的 Next 主题改的
from blog.
@lin-xin
前辈,按照你的写法,本地没问题,但是在线上 部署,会有502 的报错,我把写入流这一段注释了,发现就不会报错了,是超时问题吗?还是说写入流是异步的?
from blog.
还是直接location.href=path粗暴直接。。
from blog.
ctx.request里没files
from blog.
ctx.request里没files
需要安装 koa-body 之类的中间件
from blog.
Related Issues (20)
- Node.js 入门:Express + Mongoose 基础使用 HOT 4
- Electron 实战桌面计算器应用 HOT 2
- HTML5 桌面通知:Notification API HOT 11
- Parcel:常见技术栈的集成方式 HOT 1
- React Native组件集成到Android原生项目 HOT 2
- 使用 Node.js 开发简单的脚手架工具 HOT 16
- Node.js 应用:Koa2 使用 JWT 进行鉴权 HOT 18
- 请教一下
- vue-manage-system 后台管理系统开发总结 HOT 2
- bind()实现中的 [].concat.call(args, [].slice.call(arguments) HOT 3
- 求博客主体模板 HOT 2
- 作者你好!H5 drop event
- element ui upload怎样修改缩略图路径
- indexedDB结合vuex store使用 HOT 1
- Rollup.js: 开源JS库的打包利器
- 前端常见的加密算法介绍 HOT 3
- file-demo 拍照,xs max照片旋转 HOT 2
- Vue3 插件开发详解尝鲜版
- vue项目中实现Excel文件的上传和下载
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from blog.