Ответы пользователя по тегу Node.js
  • Кто работал с модулем multiparty?

    @j_mart
    В обработчике события 'part' (part) эта информация недоступна.
    Она доступна или в обработчике 'file' (name, file)
    form.on('file', function(name, file) {
      console.log('File name: ' + name);
      console.log('File size: ' + file.size);
    });
    /*
    name - the field name for this file
    file - an object with these properties:
      fieldName - same as name - the field name for this file
      originalFilename - the filename that the user reports for the file
      path - the absolute path of the uploaded file on disk
      headers - the HTTP headers that were sent along with this file
      size - size of the file in bytes 
    */

    или в дефолтном form.parse(request, [cb])
    form.parse(req, function (err, fields, files) {
        for (var name in files) {
            console.log('got file named ' + name + ' with size = ' + files[name]['size']);
        }
    
        console.log('Upload completed!');
        res.setHeader('text/plain');
        res.end('Received ' + files.length + ' files');
    });
    Ответ написан
    Комментировать