synapse- complex html forms
lazarus / 8-Other
----------------------------------------------------------------------
mtdew3q · 2006-02-10 07:41
Hi-
function HttpPostFileForm(const URL, FieldName, FileName: string;
const Data: TStream; const FormFields:TStrings; const ResultData:
TStrings): Boolean;
my question is what are FieldName and FileName for and how are they
used in this function header?
The function i am asking the question about seems to allow for
multiple
fields to be passed instead of a string of gets in a url or just one
fieldname
and field value in a post. Can you please give me a hypothetical
argument list for that function??
i.e. in HTTPSend.pas
function THTTPSend.HTTPMethod(const Method, URL: string): Boolean;
so one might use GET for the first parameter and
http://www.democompany.com/cgi-bin/comments.exe?Name=Matthew+Foley
&Age=32 etc.
If i understand what is going on right the arguments for get and post
are
being supplied to some file on a server location and a result is being
returned in a memo field.
I hope i am on the right track figuring this out. I just fired up
Lazarus
today and decided to expirement with Synapse. I'd like to find a use
or two that i can play around with. Nothing serious --just fun.
thanks,
jim
----------------------------------------------------------------------
mtdew3q · 2006-02-10 19:41
Hi-
>>The function i am asking the question about seems to allow for
multiple
>>fields to be passed instead of a string of gets in a url or just one
>>fieldname
>>and field value in a post. Can you please give me a hypothetical
>>argument list for that function?? "
the above seems incorrect as i have done some more reading and i found
this
"{:A very useful function, and example of use can be found in the
THTTPSend
object. It implements the POST method of the HTTP protocol. This
function is
good for POSTing form data. It sends the POST method for a URL
document to
an HTTP server. You must prepare the form data in the same manner as
you would
the URL data, and pass this prepared data to "URLdata". The following
is
a sample of how the data would appear:
'name=Lukas&field1=some%20data'.
The information in the field must be encoded by EncodeURLElement
function.
The returned document is in the "Data" stream. Returns boolean TRUE
if all
went well.}
function HttpPostURL(const URL, URLData: string; const Data: TStream):
Boolean;"
so evidently urldata preparation is very similar for both get and
post.
function HttpGetText(const URL: string; const Response: TStrings):
Boolean;
in HttpGetText the url and data are grouped together in URL
function HttpPostURL(const URL, URLData: string; const Data: TStream):
Boolean;
in HttpPostURL the URL is separate from the form data URLData
so i guess i am still wondering about the purpose behind HTTPpostFile
and how to supply the arguments and what the parameters actually
represent. At least i made a little leap forward
in beginning to understand HttpPostURL ---
below this line is function declaration and a brief description of
what i am confused with.
thanks for any help,
jim
I have adapted the HTTPpostFile to allow you to upload the file and
form fields together, instead of just the file. If you wish, add it to
HTTPSend.pas
function HttpPostFileForm(const URL, FieldName, FileName: string;
const Data: TStream; const FormFields:TStrings; const ResultData:
TStrings): Boolean;
----------------------------------------------------------------------
mtdew3q · 2006-02-12 22:46
i decided i think i can use what i have for now.