I have zip file that I want to encode and send it as string and decode and save it in server side:
This the code of the encoding in client (JS):
var fileAsText = ''
var reader = new FileReader()
reader.onload = function (event) {
  fileAsText = encodeURIComponent(event.target.result)
}
reader.readAsText(zipFile)
zipFile is the input File object (uploaded by the user).
The fileAsText string I'm sending as Post inside JSON (this is the reason I'm using encodeURIComponent)
Everything works fine, but in server side I want to take this string and decode it back to binary (zip file) and extract it. and I want to get exactly the same file the user upload in client side.
This is my code in c#:
 using (var bw = new BinaryWriter(File.Open("fileTest.zip", FileMode.Create)))
 {
      bw.Write(HttpUtility.UrlDecode(fileAsText));
 }
The problem: I don't get the same file (the binary data is diffrent)
I believe the decoder HttpUtility.UrlDecode is not fit to encodeURIComponent
Any idea how to get the same file binary data uploaded by the user?
 
    