i prefer using PB's native Input/writestring commands.
(crossplattform perhaps)
are there any examples out there how to write a simple
cgi.exe with a simple html example ?
cannot found any in the example-folder........
That is what i have today:
Purebasic (Api) Code:
Code: Select all
hInput = GetStdHandle_(#STD_INPUT_HANDLE)
SetConsoleMode_(hInput, #ENABLE_LINE_INPUT|#ENABLE_ECHO_INPUT|#ENABLE_PROCESSED_INPUT)
*ContentLength = AllocateMemory(128)
ContentLength = Val(PeekS(*ContentLength, GetEnvironmentVariable_("CONTENT_LENGTH", *ContentLength, 128)))
FreeMemory(*ContentLength)
*Buffer = AllocateMemory(ContentLength)
ReadFile_(hInput, *Buffer, ContentLength, @bRead, 0)
Input$ = PeekS(*Buffer)
FreeMemory(*Buffer)
CloseHandle_(hInput)
hOutput = GetStdHandle_(#STD_OUTPUT_HANDLE)
HttpAnswer$ = "Content-type: text/html"+Chr(10)+Chr(13)+Chr(10)+Chr(13)+"<html><header><title>Answer from CGI</title></header><body>Hi, received your data:<br>"
HttpAnswer$+StringField(StringField(Input$, 1, "&"), 1, "=")+": "+StringField(StringField(Input$, 1, "&"), 2, "=")+"<br>"+StringField(StringField(Input$, 2, "&"), 1, "=")+": "+StringField(StringField(Input$, 2, "&"), 2, "=")
HttpAnswer$+"</body></html>"
WriteFile_(hOutput, @HttpAnswer$, Len(HttpAnswer$), @Written, 0)
CloseHandle_(hOutput)
and the html for the XAMP (apache) server:
Code: Select all
<H3>MultiImage Request Form cgitest</H3>
<P>
<FORM ACTION="../cgi-bin/CGIMIMAGE.exe" METHOD="POST" ENCTYPE="multipart/form-data">
<INPUT TYPE=FILE NAME="P1_imagefile" SIZE=35 MAXLENGTH=50><BR>
</P>
<P>
<INPUT TYPE="submit" VALUE="Send the pictures">
</P>
</FORM>
any help ?