Jason Essington schrieb:
Christain
Basically what you are doing with Mark's classes is implementing RFC 1867
The DoLongTask event just compiles the post content and sends it off.
So to understand what is going on there have a look at:
http://www.faqs.org/rfcs/rfc1867.html
It explains how to construct the post content with multiple form
fields/files
once you understand that, it is a simple matter of adding those parts to
the code :-)
-jason
Yes, i know how it works on HTML and PHP.
But the syntax on RB is strange. Here is the code thats working. Only
with the name of the file and the binary of the file. i have testet a
lot of things bringing more variables to it, but it does not work.
Is there a simpler way to do this ?
Christian
// Added to support progress dialog
myPostSocket.myTask = me
me.TaskMaximum = fileToUpload.Length ' bytes being uploaded
me.TaskProgress = 0
me.TaskDescription = "Uploading " + fileToUpload.Name + "..."
Dim data, rawdata, nl, encodedFileName,funktion As String
Const boundary = "--------0xKhTmLbOuNdArY"
nl = chr(13) + chr(10) ' CRLF, used as MIME end-of-line character
// Step 1: get file data in uploadable form
Dim bs As BinaryStream
bs = fileToUpload.OpenAsBinaryFile
rawdata = bs.Read(fileToUpload.Length) ' gulp!
// Debugging step...
EF_Result.SelText = "Uploading " + FormatLen(fileToUpload.Length) + "
bytes..." + EndOfLine
EF_Result.SelStart = 9999999
encodedFileName = EncodeURLComponent(fileToUpload.Name) ' convenience
data="--" + boundary + nl
data = data + _
"Content-Disposition: form-data; name=""userfile""" + nl + nl + _
encodedFileName + 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
myPostSocket.yield = true ' be nice...
myPostSocket.SetPostContent data, "multipart/form-data, boundary=" +
boundary
myPostSocket.allFinished = False ' set up flag so we can know when
upload is done...
myPostSocket.post "http://www.server.com/repository/test.php"
while not myPostSocket.allFinished
me.CheckCancel
wend
_______________________________________________
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>