首页 诗词 字典 板报 句子 名言 友答 励志 学校 网站地图
当前位置: 首页 > 教程频道 > 网站开发 > CGI >

cgi 下载文件解决方法

2012-02-22 
cgi 下载文件web是这样写的:htmlheadtitleTest/title/headbodyform actioncgi-bin/PostTes

cgi 下载文件
web是这样写的:
<html>
<head>
  <title>Test</title>
</head>
<body>
<form action="cgi-bin/PostTest.cgi" method="POST">
  <input type="file" name="file" value="" />
  <input type="submit" value="Submit" />
</form>
</body>
</html>

我想点击Submit之后PostTest.cgi 可以接受到上传的文件,
不知道用c 怎么处理。可以使用libcgi这个库。

我的代码是这样的:可是无法实现。

C/C++ code
#include <stdio.h>#include "cgi.h"int main(){    cgi_init();    cgi_process_form();    cgi_init_headers();    puts(""        "<!DOCTYPE html PUBLIC '-//W3C//DTD HTML 4.01 Transitional//EN'>"        "<html>"        "<head>"        "       "         " <meta http-equiv='content-type' content='text/html; charset=ISO-8859-1'>"        "       "         "   <meta name='author' content='Rafael Steil'>"          "    <title>LIBCGI Examples</title>"           "   </head>"           "  <body text='#000000' bgcolor='#ffffff' link='#0000ee' vlink='#551a8b' alink='#0000ee'>"        "");     if (cgi_param("name"))     {                printf("name: %s<br>", cgi_param("name"));     }     else     {                puts("name: Empty<br>");     }     if (cgi_param("number"))     {                printf("number: %s<br>", cgi_param("number"));     }     else     {                puts("number: Empty<br>");     }      //char **lines;     //unsigned int total, i;    // printf("Content-Type:   application/xml\n\n");     printf("Content-Disposition:   attachment;   filename=DOWNLOAD.xml\n\n");    printf("file name = : %s<br>", cgi_param("file"));    FILE *fp = fopen(cgi_param("file"), "rb");     if(fp != NULL)     {        printf("Open file [%s] Successfully<br>", cgi_param("file"));     }     else     {        printf("Open file [%s] Erroy<br>", cgi_param("file"));     }     puts(""        "</body>"        "</html>"        "");        cgi_end();        return 0;}                           


[解决办法]
cgi.h 和 cgi.cpp 文件能给我看看吗》?
[解决办法]
cgi程序如果在vs6.0里面的话,服务器用apache运行cgi程序需要配置哪些东西呀?

热点排行