蓝森林首页 | 返回主页 | 本站地图 | 站内搜索 | 联系信箱 | -->
 您目前的位置:首页 > 自由软件 > 技术交流 > 应用编程 -->


    

蓝森林 http://www.lslnet.com 2006年8月16日 14:08

cgi 下载不了文件的问题 救命!!

我有一个c语言写的cgi download.cgi 这里面把一个服务器上的备份文件读出来加上一个http头之后再printf
(web server可以把printf弄到http模版里)printf如下:
printf("Content-Disposition: attachment;filename=%s\n", filename);
printf("Content-Transfer-Encoding: binary\n");
printf("Accept-Ranges: bytes\n");
printf("Content-Length: %ld\n", finfo.st_size);
printf("Connection: close\n");
printf("Content-type: application/octet-stream\n");
printf("\n");
然后就接着printf备份文件的内容:
for(sent = 0; (ch = fgetc(fp)) != EOF; sent++)
{
putc(ch, stdout);
}

free(file);
fclose(fp);


然后在一个页面的模版里有一个图片按钮通过javascript 执行这个download.cgi

function current_export_entry()
{
urlname="/cgi-bin/rtal/log-export.cgi";

if(confirm("Are you sure to export?") == false)
return;

window.location=urlname;
}
。。。。。。。。。。。。
。。。。。。。。。。。。
<a href="#" onclick="javascript:current_export_entry()"> <img src="/images/current_export.gif" alt="current_export" value="current_export" border=0> </a>

但是:
当我点击这个图片按钮的时候,虽然download.cgi可以执行。但是下载文件的时候ie却弹出不能下载的对话框:
cannot download download.cgi from 10.10.xx.
Internet Explorer was not able to open this Internet site. the request site is ether unavailable or cannot be found.try again.


奇怪的是:当我在页面上用一个按钮而不用图片来执行cgi的时候是可以下载的!但是下载的时候显示的文件名是download.cgi而不是我的备份文件名 按钮如下:

<td>
<form name="form_export" method="post" action="/cgi-bin/rtal/log-export.cgi">
<div align="center">
<input type="submit" name="export" value="导出日志">
</div>
</form>
</td>



Copyright © 1999-2000 LSLNET.COM. All rights reserved. 蓝森林网站 版权所有。 E-mail : webmaster@lslnet.com