0

我有一个输入字段,例如:

input(type='file', id='avatar', name='avatar', class='fivecol', accept='image/*')

在我的控制器中,我检查req.files.avatar...即使它是空的,输出仍然会被记录并暂时存储(某些东西)在/uploads.

这是一个控制台日志req.files.avatar

{ avatar:
   { domain: null,
     _events: null,
     _maxListeners: 10,
     size: 0,
     path: 'uploads/aa7571f48cc1d0a3d1242d737f8c5fa0',
     name: '',
     type: 'application/octet-stream',
     hash: false,
     lastModifiedDate: null,
     _writeStream:
      { domain: null,
        _events: null,
        _maxListeners: 10,
        path: 'uploads/aa7571f48cc1d0a3d1242d737f8c5fa0',
        fd: 21,
        writable: false,
        flags: 'w',
        encoding: 'binary',
        mode: 438,
        bytesWritten: 0,
        busy: false,
        _queue: [],
        _open: [Function] },
     length: [Getter],
     filename: [Getter],
     mime: [Getter] } }

为什么要这样做?此外,该文件0 bytes夹中有一个/uploads名为aa7571f48cc1d0a3d1242d737f8c5fa0(或每次生成其他随机哈希)的文件。

另外,为什么不快速清除那些临时上传的文件/uploads呢?

4

0 回答 0