专注收集记录技术开发学习笔记、技术难点、解决方案
网站信息搜索 >> 请输入关键词:
您当前的位置: 首页 > 高性能WEB开发

分享一点代码(小型C web开发框架)共11篇章 (含全部源代码),范例:用C语言实现的一个WEB 文件下传

发布时间:2010-05-20 14:01:29 文章来源:www.iduyao.cn 采编人员:星星草
分享一点代码(小型C web开发框架)共11篇章 (含全部源代码),范例:用C语言实现的一个WEB 文件上传
分享一点代码(小型C web开发框架)共11篇章 (含全部源代码),范例:用C语言实现的一个WEB 文件上传
在 windows IIS Apache linux Apache IE Firefox 均测试通过
编译:用Vs2008和GCC 均可编译
共11篇章 (含全部源代码),欢迎各位专家,高手指正!

#include "cgic.h"

#define BufferLen 1024
int cgiMain(void){
  int i = 0;
  char fn[1024];
  char type[1024];
  char name[1024];
  char **responses;

  cgiFilePtr file;
  FILE *fp;
  int targetFile;
  char fileNameOnServer[64];
  char contentType[1024];
  char buffer[BufferLen];
  char *tmpStr=NULL;
  int size;
  int got,t;
  cgiHeaderContentType("text/html");
  fprintf(cgiOut, "<title>C WEB</title>n");
  fprintf(cgiOut, "<h1>C语言开发</h1>n");

  fprintf(cgiOut, "<br>cgiServerSoftware %s n", cgiServerSoftware);
  fprintf(cgiOut, "<br>cgiServerName %s n", cgiServerName);
  fprintf(cgiOut, "<br>cgiGatewayInterface %s n", cgiGatewayInterface);
  fprintf(cgiOut, "<br>cgiServerProtocol %s n", cgiServerProtocol);
  fprintf(cgiOut, "<br>cgiServerPort %s n", cgiServerPort);
  fprintf(cgiOut, "<br>cgiRequestMethod %s n", cgiRequestMethod);
  fprintf(cgiOut, "<br>cgiPathInfo %s n", cgiPathInfo);
  fprintf(cgiOut, "<br>cgiPathTranslated %s n", cgiPathTranslated);
  fprintf(cgiOut, "<br>cgiQueryString %s n", cgiQueryString);
  fprintf(cgiOut, "<br>cgiRemoteHost %s n", cgiRemoteHost);
  fprintf(cgiOut, "<br>cgiRemoteAddr %s n", cgiRemoteAddr);
  fprintf(cgiOut, "<br>cgiAuthType %s n", cgiAuthType);
  fprintf(cgiOut, "<br>cgiRemoteUser %s n", cgiRemoteUser);
  fprintf(cgiOut, "<br>cgiRemoteIdent %s n", cgiRemoteIdent);
  fprintf(cgiOut, "<br>cgiContentType %s n", cgiContentType);
  fprintf(cgiOut, "<br>cgiAccept %s n", cgiAccept);
  fprintf(cgiOut, "<br>cgiUserAgent %s n", cgiUserAgent);
  fprintf(cgiOut, "<br>cgiReferrer %s n", cgiReferrer);

  cgiFormString( "fn", fn , sizeof( fn ) );
  cgiFormString("type", type, sizeof( type ));  
  cgiFormString("name", name, sizeof( name ));  
  fprintf( cgiOut , "<br/>fn:" );
  fprintf( cgiOut , fn );

  fprintf( cgiOut , "<br/>type:" );
  fprintf( cgiOut , type );

  fprintf( cgiOut , "<br/>name:" );
  fprintf( cgiOut , name );

  if(strcmp(cgiRequestMethod, "GET")==0)
  {
  fprintf(cgiOut, "<form target='_blank' method='post' enctype='multipart/form-data' > ");
  fprintf(cgiOut, " <input name='file' id='file' type='file' /> <input name='submit' type='submit' /> ");
友情提示:
信息收集于互联网,如果您发现错误或造成侵权,请及时通知本站更正或删除,具体联系方式见页面底部联系我们,谢谢。

其他相似内容:

热门推荐: