一个基础问题
我在win2000下的IIS中设制了一个虚拟目录,并在下面放了两个文件:
1.index.htm:
<html>
<body>
<form action='http://localhost/cgi-win/readpost.exe' method='post'>
1. corpname:ニ」コ
<input type="text" name="corpname">
<input type="submit">
</form>
</body>
</html>
2.readpost.exe 其原文件为:
#include <stdlib.h>
#include <stdio.h>
void readPostData(char **aString){
char *queryString;
int contentLength;
char *sizeString;
int i;
sizeString=getenv("CONTENT_LENGTH");
if(sizeString)
contentLength=atoi(sizeString);
else
contentLength=0;
if(0!=contentLength)
queryString=(char *)malloc(sizeof(char)*(contentLength+1));
else
queryString=(char*)0;
if(queryString){
i=0;
while(i<contentLength)
queryString[i++]=fgetc(stdin);
queryString[i]='\0';
}
*aString=queryString;
}
void main(int argc,char *argv[]){
char *requestType;
char *data=(char *)0;
printf("Content-type:text/plain\n\n");
printf("The POST data is:\n");
requestType=getenv("REQUEST_METHOD");
if(requestType && !strcmp(requestType,"POST")){
readPostData(&data);
if(data!=(char*)0)printf("%s\n",data);
}
printf("Request_method is:%s\n",requestType);
exit(0);
}
当浏览器访问到readpost.ext时就出现错误,是不是不能这样做,还有就是需不需要CGI接口什么的?还请赐教。
问题点数:30、回复次数:2Top
1 楼chinesun(郑返)回复于 2003-09-05 15:42:16 得分 15
需要执行的权限Top
2 楼scalps(悲伤的梦)回复于 2003-09-06 20:05:16 得分 15
给这个目录以执行的权限,不过这样的话不是很好,还是专门把有执行权限的程序放一个专有目录下去,比如/cgi-bin/
Top




