TypeError: Cannot read property 'length' of undefined using bodyParser

I am trying to make async file uploads using xhr:

Here my frontend code:

  ...
  $el = $(selector)
  el = $el.get 0 // Worls
  data = new FormData()
  data.append "file", el.files[0]
  $.ajax
    url: "//#{window.config.host}/api/v1/versions/..."
    type: "POST"
    data: data
    processData: false
    success: (data) ->
      console.log data

Backend (bodyParser setup)

  app.bodyParser = express.bodyParser
    keepExtensions:true,
    uploadDir: path.join __dirname,'/temp/'

Headers sent:

Host: localhost:1234
User-Agent: Mozilla/5.0 (Windows NT 6.1; WOW64; rv:30.0) Gecko/20100101 Firefox/30.0
Accept: */*
Accept-Language: fr,fr-fr;q=0.8,en-us;q=0.5,en;q=0.3
Accept-Encoding: gzip, deflate
Content-Type: application/x-www-form-urlencoded; charset=UTF-8
Referer: http://localhost:9000/
Content-Length: 323651
Origin: http://localhost:9000
Connection: keep-alive
Pragma: no-cache
Cache-Control: no-cache

Request body sent

-----------------------------13495352912601
Content-Disposition: form-data; name="file"; filename="logo.png"
Content-Type: image/png

PNG
...
Å   !ýâB!Ìe>ýÌ×<:ìî×w'<ôïÜ¢ïý÷ï¶}Ú=ýçûÒ¸ï¼r{ߣ§fÐñÝâ¤
'µâþAqB!Bf3Ñü¿}ԣà LÞõкM;¿èVßþÏÝ~üûòëÓ
xÉKqBqÒw(Né'B!d6ca"¿ys%Wï¿Å/8A¸¤é%'=Á¬5IEND®B`
-----------------------------13495352912601--

Answers


Need Your Help

reimp.exe working with TDM-GCC

mingw gcc4.7

I use MinGW version compile by TDM that can be found here

About UNIX Resources Network

Original, collect and organize Developers related documents, information and materials, contains jQuery, Html, CSS, MySQL, .NET, ASP.NET, SQL, objective-c, iPhone, Ruby on Rails, C, SQL Server, Ruby, Arrays, Regex, ASP.NET MVC, WPF, XML, Ajax, DataBase, and so on.