Git Product home page Git Product logo

Comments (7)

xiangrenya avatar xiangrenya commented on August 15, 2024 1
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
})

breaking-changes-in-v3/4

The files property has been moved to ctx.request.files. In prior versions, files was a property of ctx.request.body

from blog.

julyL avatar julyL commented on August 15, 2024

线上博客用的是hexo theme还是自己写的

from blog.

lin-xin avatar lin-xin commented on August 15, 2024

@julyL 基于 hexo 的 Next 主题改的

from blog.

jgchenu avatar jgchenu commented on August 15, 2024

@lin-xin
前辈,按照你的写法,本地没问题,但是在线上 部署,会有502 的报错,我把写入流这一段注释了,发现就不会报错了,是超时问题吗?还是说写入流是异步的?
02b0753d3998cba060bac06955455ca

from blog.

Thyiad avatar Thyiad commented on August 15, 2024

还是直接location.href=path粗暴直接。。

from blog.

shenxiang216 avatar shenxiang216 commented on August 15, 2024

ctx.request里没files

from blog.

Pulset avatar Pulset commented on August 15, 2024

ctx.request里没files

需要安装 koa-body 之类的中间件

from blog.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo 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.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.