【发布时间】:2017-03-04 07:26:41
【问题描述】:
我正在使用 Sails JS v11.05。
文件上传不是必填字段。
如何检查文件是否已上传?
通常,我使用
if (!req.param('param')) {
// param does NOT exist - was not uploaded
// This does not apply to file input params.
}
// However, the following will break as it will start a listener (upstream)
if (!req.file('param')) {
// File was not uploaded
}
我只想知道一个文件是否是输入,所以如果它没有上传,我就懒得调用 req.file('file').upload()。
想法?
【问题讨论】:
-
你应该
sails.log(res);。那里肯定有一些东西可以用于此,即响应代码? -
不,请看下面我的回答。
标签: node.js sails.js skipper sails-skipper