htmlnode.jsexpresspugmultipartform-data

[Error: MultipartParser.end(): stream ended unexpectedly: state = START]


i receive this error when i try to send a form

link(rel='stylesheet',href='/stylesheets/home/profile/home_menu.css')
script(type='text/javascript',src='/javascripts/perfil_editar.js')

#logo_usuario
    img(src='')
#nombre_usuario(class='titulo1') 
    input(type='text',placeholder='',id="perfil_inputdatos_usuario")
    input(type="text",placeholder="",id="perfil_inputdatos_tipo")
#datos_fondo
#perfil_publicaciones_fondo
    select(id='perfil_publicaciones_lista',size='2')
        option(value='si', selected='selected') Publicacion 1
        option(value='no') Publicacion 2
    #perfil_publicaciones_ir
        t Ir    

#perfil_busquedas_fondo
    select(id='perfil_busquedas_lista',size='2')
        option(value='si', selected='selected') Busqueda 1
        option(value='no') Busqueda 2
    #perfil_busquedas_ir
        t Ir    


#ubicacion_fondo

#datos_usuario
    #perfil_datos_nombre
        img(src='/images/logo_nombre2.png')     
    #perfil_datos_telefonos
        img(src='/images/logo_telefono2.png')   
    #perfil_datos_direccion
        img(src='/images/logo_direccion2.png')
    #perfil_datos_mail  
        img(src='/images/logo_web2.png')

    form(action='/nuevaEdicion',method='post',enctype='multipart/form-data',id='editar')
        input(type='name',name='perfil_inputdatos_nombre',id='perfil_inputdatos_nombre')
        input(type='name',name='perfil_inputdatos_direccion',id='perfil_inputdatos_direccion')
        input(type='name',name='perfil_inputdatos_telprivado', id='perfil_inputdatos_telprivado')
        input(type='name',name='perfil_inputdatos_telcontacto',id='perfil_inputdatos_telcontacto')
        input(type='name',name='perfil_inputdatos_telcelular',id='perfil_inputdatos_telcelular')
        input(type='name',name='perfil_inputdatos_mail',id='perfil_inputdatos_mail')

#datos_titulo(class='titulo2')
    t Datos

#perfil_publicaciones_titulo(class='titulo2')
    t Publicaciones Realizadas
#perfil_busquedas_titulo(class='titulo2')
    t Busquedas Guardadas

#ubicacion_titulo(class='titulo2')
    t Ubicacion
#perfil_editar
    t Editar Perfil

i render this with this script in ajax

$(document).ready(function(){

    $('.perfil_nav a').click(function(){
      var objAttr=$(this).attr("id");
      $('#informacion').animate({height:'hide'},600,
        function()
            {
              $.ajax({
                url: "/profile_arquitecture_/"+objAttr,
              }).done(
                function(msg) {$('#informacion').html(msg);});
            });
        $('#informacion').fadeIn(600);
    });

});

only change one div named informacion from this file home.jade

extends layout

append head
    link(rel='stylesheet',href='/stylesheets/home/home.css')
    script(type="text/javascript",src="https://maps.google.com/maps/api/js?sensor=false&language=es")
    script(type='text/javascript',src='/javascripts/home_menu.js')

block contenido_central
    #contenido
        #capa_principal
            #barra_sesion
                #barra_menu
                    ul(class='perfil_nav')
                        li(class='first') 
                            a(href='#',id='miperfil') Perfil
                        li 
                            a(href='#',id='mispublicaciones') Mis Publicaciones
                        li 
                            a(href='#',id='misbusquedas') Mis Busquedas     
                        li(class='last') 
                            a(href='#',id='mismensajes') Mensajes
            #informacion

appending the form.jade in the informacion div in the routes.perfil.js it renders with res.render

exports.editarPerfil=function(req,res)
{
    console.log(req.body)   
    res.render('home/nosotros',
    {title: 'Bienvenido ',
     sessionUser: req.session.passport.user
    });
}

in the app.js

app.post('/nuevaEdicion',express.bodyParser(),routes.perfil.editarPerfil);

this is the error in console

[Error: MultipartParser.end(): stream ended unexpectedly: state = START]
{}

EDIT 2:

i discover that when i put in form

enctype="application/x-www-form-urlencoded"

the page freeze but when i put

enctype="multipart/form-data"

i have to click many times in submit but the form works properly and the result in console is

{ perfil_inputdatos_nombre: '',
  perfil_inputdatos_direccion: '',
  perfil_inputdatos_telprivado: '',
  perfil_inputdatos_telcontacto: '',
  perfil_inputdatos_telcelular: '',
  perfil_inputdatos_mail: '' }

when i put

enctype="text/plain"

the form works properly fine fast and no problem but the result in console is

{}

so i think the problem is in html but any can solve this??? tanx

this is the profile id handler

exports.profile_pages=function(req,res)
{
    var usuario_actual=req.session.passport.user;
    mongo.dbusuarios.infoUsuario(usuario_actual,function(err,items)
    {
        if(err) throw err;
        res.render('home/profile/home_'+req.params.id,
        {
            title:'',
            layout:false,
            datos_perfil:items,
        });
    });
};

Solution

  • Your click handler should return false to keep the browser from trying to process the click. That may be what's messing you up. If that doesn't help, console.log() the value of objAttr and make sure there really is a jade file corresponding to its value.