我正在使用 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() 。
想法?