Posting base64 with New HTTPSOCKET

I am converting my old HTTPSOCKETs to Xojo.net.HttpSockets . Should I be encoding all the new form data with EncodeURLComponent?
The old code worked fine without extra encoding, but the new socket does not send the base64 data the same way. Did setFormData handle that for us in the old socket? I thought the old socket used the x-www-form-urlencoded type.

Dim form as New Dictionary
form.value("name") = "picture name"
form.value("base64img") = app.imageToBase64( SpecialFolder.Desktop.Child( "test.jpg" ) )

// old way worked fine this way,  no encodeURLComponent necessary:
'SocketProject.setFormData form
'SocketProject.post( "http://www.myserver.com/scripts/expectingBase64imageAndName.php")

//new socket needs the EncodeURLComponent on the base64 data.
//dictionary form is being passed to a method of the subclassed Xojo.net.HttpsSocket
Dim postData AS Text
For i As Integer = 0 To form.Count - 1
    Dim baseStr As Text = form.Key(i).StringValue.ToText  +"=" +Trim(form.Value(form.Key(i)).StringValue).ToText
    if form.Key(i).StringValue = "base64img" then
      baseStr = form.Key(i).StringValue.ToText  +"=" +EncodeURLComponent(Trim(form.Value(form.Key(i)).StringValue)).ToText
    end
 
    If i < form.count - 1 Then // We won't add a "&" to the last key/value pair
      postData = postData + baseStr + "&"
    Else
      postData = postData + baseStr
    End If
 Next
  
  Dim data As Xojo.Core.MemoryBlock = Xojo.Core.TextEncoding.UTF8.ConvertTextToData(postData)
  SetRequestContent(data, "application/x-www-form-urlencoded")
  Send("POST", "http://www.myserver.com/scripts/expectingBase64imageAndName.php")

I can’t say why it stopped working, but generally speaking x-www-form-urlencoded forms are not appropriate when uploading binary data like a picture. If possible, you should consider changing the design to use a multipart/form-data encoded form.

Thanks Andrew, I will try that. I liked the old SetFormData so I didn’t need to create the multipart/form-data. I never had any issues doing it that way for base64 encoded images.
I stumbled across this link of yours - which is what I was trying to do with Xojo.Net.HttpSocket and x-www-url-encoded: http://www.boredomsoft.org/file-uploads-form-encodings-and-xojo.bs