On Feb 5, 2007, at 8:20 AM, Sam DeVore wrote:
How about posting some code to look at?
you could use something like http://pastie.caboo.se/
anyone know of a service that works for markup of realbasic?
Sam D
On Feb 4, 2007, at 12:06 PM, Guyren Howe wrote:
I need to do an upload to a PHP server from REALbasic.
I found an example from Bucktail Software and have looked at the
relevant RFC. I believe I'm doing everything correctly. Using an
HTTP sniffer, I'm sending virtually the same thing as Firefox (I
can't set the referer header for some reason).
All I ever get is an error 3 from the server.
Does anyone have any idea what I might be missing?
My code is in mostly two places. There's this:
Dim s As New UploadSocket(Me.TheClient)
Dim data As String =TheFile.EncodeForUpload("file0")
s.ClearRequestHeaders
s.SetRequestHeader "Content-Length", Str(data.LenB +
MissingFields.LenB)
s.SetRequestHeader "Accept-Charset", "ISO-8859-1,utf-8;q=0.7,*;q=0.7"
s.SetRequestHeader "Connection", "keep-alive"
s.SetRequestHeader "Keep-Alive", "500"
s.SetRequestHeader "HTTP-Referer", HTMLEncode
(MainWindow.CurrentPath.Replace("/Home", ""))
s.SetRequestHeader "Accept-Language", "en-us,en;q=0.5"
s.SetRequestHeader "Accept", "text/xml,application/xml,application/
xhtml+xml,text/html;q=0.9,text/plain;q=0.8,image/png,*/*;q=0.5"
s.SetRequestHeader "User-Agent", "Mozilla/5.0 (Macintosh; U; Intel
Mac OS X; en-US; rv:1.8.1.1) Gecko/20061204 Firefox/2.0.0.1"
MainWindow.LoginSocket1.ApplyCookies s
s.SetPostContent data + MissingFields, "multipart/form-data;
boundary=" + boundary
s.Post UploadPreamble + HTMLEncode(MainWindow.CurrentPath.Replace
("/Home", ""))
and EncodeForUpload looks like this:
Dim bs As BinaryStream = f.OpenAsBinaryFile
Dim rawdata As String = bs.Read(f.Length)
Dim encodedFileName As String = EncodeURLComponent(f.name)
Return "--" + boundary + nl + _
"Content-Disposition: form-data; name=""" + EncodeURLComponent
(fieldName) +"""; filename=""" + _
encodedFileName + """" + nl +_
"Content-Length: " + STr(LenB(rawdata)) + nl + _
"Content-Transfer-Encoding: binary" + nl +_
"Content-Type: image/jpeg" + nl + _
nl + rawdata + nl
I've compared what I'm sending to what a browser is sending, and it's
virtually identical. I know I've got the length right.
I'm sending virtually the same headers as the web browser. I don't
send Accept-Encoding: gzip,deflate, and for some reason, when I try
to set referer, that is ignored.
I've spent days on this thing, which should have taken me a couple of
hours. Can anyone advise on what's going wrong?
Regards,
Guyren G Howe
Relevant Logic LLC
guyren-at-relevantlogic.com ~ http://relevantlogic.com
REALbasic, PHP, Ruby/Rails, Python programming
PostgreSQL, MySQL database design and consulting
Technical writing and training
_______________________________________________
Unsubscribe:
<[EMAIL PROTECTED]>
REAL Software has decided to consolidate this mailing list with the online Forums.
On Monday, February 12, 2007, this mailing list will no longer be active. We
encourage you to continue your REALbasic and REAL SQL Server discussions on the
Forums. If you are not presently a member of the forum, please sign up today at
<http://forums.realsoftware.com>.