My code:
var fl = getFile(); //get file from <input type file /> var xhr = new XMLHttpRequest(); xhr.open("POST", "/file_upload", true); xhr.send(fl);
However, on the server in “file_upload(conn, params)” the “params” if empty:
def file_upload(conn, params) do IO.inspect(params) # => protocol String.Chars not implemented for %{}
on the client “fl” isn’t empty
The parameters is a map, but you are not sending any parameters, when you send it you are sending it in the ‘body’, so check there.
send
This is why one should use FormData as example here:
in this example you would get params that are map, and key for file would be “webmasterfile”. So @safinto do make sure you send the form properly using FormData.