Fix undefined value
Improve uploading of pasted attachment data

Convert to binary before sending and use existing Ajax upload code.