How could i Post binary data to perl cgi?
Alejandro Tejada
capellan2000 at yahoo.com
Sat Feb 21 10:47:52 EST 2004
Hi Developers,
I have been working hard to employ
the method "post" for uploading
files to a web server.
I have used "HTTP interceptor v1.3"
to check the differences between the
data send by browsers and RR/MC.
These are the results:
Http headers send from Netscape:
POST /cgi-bin/upload.cgi HTTP/1.0
Referer: http://www.mywebsite.com/postfiles.html
Connection: Close
User-Agent: Mozilla/4.8 [en] (Win98; U)
Host: www.mywebsite.com
Accept: image/gif, image/x-xbitmap, image/jpeg,
image/pjpeg, image/png, */*
Accept-Encoding: gzip
Accept-Language: en
Accept-Charset: iso-8859-1,*,utf-8
Content-type: multipart/form-data;
boundary=---------------------------277072699622422
Content-Length: 15909
Data found after header end:
-----------------------------277072699622422
Content-Disposition: form-data; name="FILE1";
filename="C:\Mis documentos\candado.gif"
Content-Type: image/gif
GIF89aJ
Based in these results, i changed the script
to closely match the http produced by Netscape:
This was the headers result:
POST /cgi-bin/upload.cgi HTTP/1.1
Host: www.mywebsite.com
User-Agent: Metacard (Win32)
Content-Length: 15703
Content-type: multipart/form-data
Data found after header end:
Content-Disposition: form-data; name="FILE1";
filename="C:\Mis documentos\candado.gif"
Content-Type: image/gif
GIF89aJ
But the server returns
Malformed Post request. :-(
This is the script that
produced this malformed post:
on mouseUp
-- Setting httpheaders as recommended by Dave Cragg
-- in the message "HTTP headers for posting data"
put "Content-type: multipart/form-data" into
tHeaders
set the httpHeaders to tHeaders
put "http://www.mywebsite.com/cgi-bin/upload.cgi" into
tUrl
put "Content-Disposition: form-data; name=" & quote
& "FILE1" & quote & "; filename=" & quote & "C:\Mis
documentos\candado.gif" & quote into tString
put crlf after tString
put "Content-Type: image/gif" after tString
put crlf & crlf after tString
set the customprop1 of the topstack to url
"binfile:C:/Mis documentos/candado.gif"
put the customprop1 of the topstack after tString
put crlf after tString
post tString to url tUrl
-- put tString -- uncomment for debug
if the result is empty
then
put it --
set the htmltext of fld "result" to it
else
answer the result
end if
end mouseUp
If you could see the errors in this script,
post them here or send clues to my mail.
Thanks in advance.
al
=====
Visit my site:
http://www.geocities.com/capellan2000/
Search the mail list:
http://mindlube.com/cgi-bin/search-use-rev.cgi
__________________________________
Do you Yahoo!?
Yahoo! Mail SpamGuard - Read only the mail you want.
http://antispam.yahoo.com/tools
More information about the use-livecode
mailing list