使用者工具

網站工具


program:c:cgi_-_說明

查看所有環境變數

int main(int argc, char* argv[], char *envp[]) {
 
  int x;
  for (x = 0; envp[x] != NULL; ++x) {
    printf(envp[x]);
    printf("<br>\n");
  }
 
}

結果:

HTTP_HOST=192.168.100.208
HTTP_USER_AGENT=Mozilla/5.0 (Windows NT 6.1; rv:24.0) Gecko/20100101 Firefox/24.0
HTTP_ACCEPT=text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8
HTTP_ACCEPT_LANGUAGE=zh-tw,zh;q=0.8,en-us;q=0.5,en;q=0.3
HTTP_ACCEPT_ENCODING=gzip, deflate
HTTP_REFERER=http://192.168.100.20/uploadFile.htm
HTTP_CONNECTION=keep-alive
CONTENT_TYPE=multipart/form-data; boundary=---------------------------136821289713119
CONTENT_LENGTH=812
PATH=/sbin:/usr/sbin:/bin:/usr/bin
SERVER_SIGNATURE=
SERVER_SOFTWARE=Apache/2.2.13 (Unix)
SERVER_NAME=192.168.100.208
SERVER_ADDR=192.168.100.208
SERVER_PORT=80
REMOTE_ADDR=192.168.100.25
DOCUMENT_ROOT=/etc_ro/www
SERVER_ADMIN=you@example.com
SCRIPT_FILENAME=/etc_ro/www/cgi-bin/get/uploadFiles.cgi
REMOTE_PORT=3199
GATEWAY_INTERFACE=CGI/1.1
SERVER_PROTOCOL=HTTP/1.1
REQUEST_METHOD=POST
QUERY_STRING=debug
REQUEST_URI=/cgi-bin/get/uploadFiles.cgi?debug
SCRIPT_NAME=/cgi-bin/get/uploadFiles.cgi

取得 Form Data

cbReadbyte = fread(cbDataBuffer, sizeof(char), _BUFFER_CACHE_BYTE, stdin)
 
printf("cbDataBuffer = %s<br>\n",cbDataBuffer);

From Web Browser

-----------------------------211372381227652
Content-Disposition: form-data; name="filename"

Test.txt
-----------------------------211372381227652
Content-Disposition: form-data; name="filesize"

1111111
-----------------------------211372381227652
Content-Disposition: form-data; name="file"; filename="Test.txt"
Content-Type: text/plain

~~~
Test file start
this
is
a
book
.
Test file end
~~~
-----------------------------211372381227652--

From Flash

------------cH2KM7gL6Ij5GI3Ij5ei4KM7GI3ae0
Content-Disposition: form-data; name="Filename"

Test.txt
------------cH2KM7gL6Ij5GI3Ij5ei4KM7GI3ae0
Content-Disposition: form-data; name="Filedata"; filename="Test.txt"
Content-Type: application/octet-stream

~~~
Test file start
this
is
a
book
.
Test file end
~~~
------------cH2KM7gL6Ij5GI3Ij5ei4KM7GI3ae0--

From iOS

-----------------------------14737809831466499882746641449
Content-Disposition: form-data;Content-Disposition: name="userfile"; Content-Disposition: titlename="";Content-Disposition: descriptionname="";Content-Disposition: filename="Document/Test.txt"
Content-Type: application/octet-stream

~~~
Test file start
this
is
a
book
.
Test file end
~~~
-----------------------------14737809831466499882746641449--

From Android

--*****
Content-Disposition: form-data; name="filename";filename="/Document/Test.txt"
Content-Disposition: filesize="62"

~~~
Test file start
this
is
a
book
.
Test file end
~~~
--*****--
program/c/cgi_-_說明.txt · 上一次變更: 2013/10/02 07:04 (外部編輯)