at the end you need to have "--" something like:
data = data + "--" + boundry + "--"
that lack of the final "--" may be confusing the server.
I have a method that encodes multipart data (not files, just data) it
works like this:
Function EncodeFormData(form As Dictionary) As String
// bail if form is nil or empty
if form is nil then return ""
if form.Count < 1 then return ""
Dim data As String
Dim i As Integer
for i = 0 to form.Count - 1
data = data + "--" + kBOUNDARY_VALUE + EndOfLine.Windows
data = data + kDISPOSITION + kDISPOSITION_FORM_DATA + "; " +
kNAME + "=""" + form.key(i) + """" + EndOfLine.Windows
data = data + EndOfLine.Windows
data = data + form.Value(form.Key(i))
data = data + EndOfLine.Windows
next
data = data + "--" + kBOUNDARY_VALUE + "--"
System.Log(System.LogLevelDebug, data)
return data
End Function
then the socket is prepared like:
Dim content As String = EncodeFormData(form)
Dim contentType As String = kMULTIPART_FORM_DATA+", "+kBOUNDARY
+"="+kBOUNDARY_VALUE
SetPostContent(content, contentType)
To send the binary files, you'd have to add some smarts where if the
value in the dictionary was a folderItem, it would add the content
type and such before loading the file bytes, but I think it wouldn't
be too tough to add.
-jason
On Mar 29, 2006, at 2:39 PM, Christian Leicht wrote:
Mark Nutter schrieb:
Have a look at this section:
data="--" + boundary + nl
data = data + _
"Content-Disposition: form-data; name=""userfile""" + nl
+ nl + _
encodedFileName + nl
This uploads the equivalent of an HTML <input> field named
"userfile". To upload more data, repeat this section with
different values for the "name=" part and the encodedFileName
variable.
Yes i tried it this way, but have a problem.
My code (part):
=======
data="--" + boundary + nl
data = data + _
"Content-Disposition: form-data; name=""userfile""" + nl + nl
+ _
encodedFileName + nl
// add a 2nd variable
data="--" + boundary + nl
data = data + _
"Content-Disposition: form-data; name=""funktion""" + nl + nl
+ _
"test" + nl
data = data + "--" + boundary + nl
data = data + _
"Content-Disposition: form-data; name=""bildbinary"";
filename=""" + _
encodedFileName + """" + nl +_
"Content-Type: image/jpeg" + nl + _
"Content-Length: " + FormatLen(lenb(rawdata)) + nl + _
"Content-Transfer-Encoding: binary" + nl + _
nl + rawdata + nl
data = data + "--" + boundary + nl + nl
======
If i add a 2nd variable to it i became only the 2nd (test) to the
Server. The first userfile variable is not sending. And also the
File is not going to the server.
I think but can not discribe the problem with the """ or nl
(linebreaks) Syntax ?
I have between the parts set the boundarys, and it should be working.
Christian
_______________________________________________
Unsubscribe or switch delivery mode:
<http://www.realsoftware.com/support/listmanager/>
Search the archives of this list here:
<http://support.realsoftware.com/listarchives/lists.html>
_______________________________________________
Unsubscribe or switch delivery mode:
<http://www.realsoftware.com/support/listmanager/>
Search the archives of this list here:
<http://support.realsoftware.com/listarchives/lists.html>