不是普通的那种WebApplication.SendFile(LogFile,false,'',''); 下载文件,
是客户端通过程序调用IE的url参数请求下载的。
比如:http://127.0.0.1:8080/?filename=aaa.db
当客户端请求上面的地址的时候,我要找到文件然后发送过去,
朋友告诉我可以在unit ServerController; 里面的建立新Session里面来做,
我做完了,也的确可以下载了,但是出了一个新的问题,下载的内容不对,下面是我的代码:procedure TIWServerController.IWServerControllerBaseNewSession(
ASession: TIWApplication; var VMainForm: TIWBaseForm);
var sl : TStringList;
i: integer;
LogFile,AnalyzeReport:string;
begin
ASession.Data := TIWUserSession.Create(nil);
LogFile := ExtractFilePath(Application.ExeName) + 'Esa03\'+ WebApplication.RunParams.Values['file'];
AnalyzeReport := ExtractFilePath(Application.ExeName) + 'Esa03\'+WebApplication.RunParams.Values['file']; if ''<>Trim(WebApplication.RunParams.Values['type']) then begin
case StrToInt(Trim(WebApplication.RunParams.Values['type'])) of
0:ResponseFile(LogFile); //
1:ResponseFile(AnalyzeReport); //
end;
end; if ''<>Trim(WebApplication.Request.QueryFields.Values['filelist']) then begin
sl := TStringList.Create;
sl.Clear;
sl := CutFileList(Trim(WebApplication.Request.QueryFields.Values['filelist']));
for i := 0 to sl.Count -1 do
delete_log_file(ExtractFilePath(Application.ExeName)+'\Esa03\'+ sl.Strings[i]);
sl.Free;
end;
end;
procedure ResponseFile(LogFile:string);
var HttpContent : array[0..512000]of char;
f:TFileStream;
hFile:THANDLE;
FileSizeHigh:LongWord;
iSize:integer;
begin
try
hFile := CreateFile(PChar(LogFile),GENERIC_READ,FILE_SHARE_READ,nil,OPEN_EXISTING,FILE_ATTRIBUTE_NORMAL,0);
iSize := GetFileSize(hFile,@FileSizeHigh);
ResponseHttpHeader(LogFile,iSize); //send http header
CloseHandle(hFile);
WebApplication.SendFile(LogFile,false,'','');
except
Abort;
end;
end;我下载下来的文件所有的内容都被intraweb给修改了,内容如下:<HTML><HEAD><TITLE></TITLE><meta http-equiv="cache-control" con_tent="no-cache">
<meta http-equiv="pragma" con_tent="no-cache">
<NOSCRIPT><HTML><BODY>Your browser does not seem to support JavaScript. Please make sure it is supported and activated</BODY></HTML></NOSCRIPT>
<SCRIPT>
var ie4 = (document.all)? true:false;
var ns6 = (document.getElementById)? true && !ie4:false;
function Initialize() {
var lWidth;
var lHeight;
if (ns6) {
lWidth = window.innerWidth - 30;
lHeight = window.innerHeight - 30;
} else {
lWidth = document.body.clientWidth;
lHeight = document.body.clientHeight;
}
document.forms[0].elements["IW_width"].value = lWidth;
document.forms[0].elements["IW_height"].value = lHeight;
document.forms[0].submit();
}</SCRIPT></HEAD><BODY on_load="Initialize()">
<form method=post action="">
<input type=hidden name="IW_width">
<input type=hidden name="IW_height">
<input type=hidden name="IW_SessionID_" value="016r1cy29408l6swg16r1cyvn1">
<input type=hidden name="IW_TrackID_" value="0">
</form></BODY></HTML>请问大家,我改怎么办啊?????????急死我了
是客户端通过程序调用IE的url参数请求下载的。
比如:http://127.0.0.1:8080/?filename=aaa.db
当客户端请求上面的地址的时候,我要找到文件然后发送过去,
朋友告诉我可以在unit ServerController; 里面的建立新Session里面来做,
我做完了,也的确可以下载了,但是出了一个新的问题,下载的内容不对,下面是我的代码:procedure TIWServerController.IWServerControllerBaseNewSession(
ASession: TIWApplication; var VMainForm: TIWBaseForm);
var sl : TStringList;
i: integer;
LogFile,AnalyzeReport:string;
begin
ASession.Data := TIWUserSession.Create(nil);
LogFile := ExtractFilePath(Application.ExeName) + 'Esa03\'+ WebApplication.RunParams.Values['file'];
AnalyzeReport := ExtractFilePath(Application.ExeName) + 'Esa03\'+WebApplication.RunParams.Values['file']; if ''<>Trim(WebApplication.RunParams.Values['type']) then begin
case StrToInt(Trim(WebApplication.RunParams.Values['type'])) of
0:ResponseFile(LogFile); //
1:ResponseFile(AnalyzeReport); //
end;
end; if ''<>Trim(WebApplication.Request.QueryFields.Values['filelist']) then begin
sl := TStringList.Create;
sl.Clear;
sl := CutFileList(Trim(WebApplication.Request.QueryFields.Values['filelist']));
for i := 0 to sl.Count -1 do
delete_log_file(ExtractFilePath(Application.ExeName)+'\Esa03\'+ sl.Strings[i]);
sl.Free;
end;
end;
procedure ResponseFile(LogFile:string);
var HttpContent : array[0..512000]of char;
f:TFileStream;
hFile:THANDLE;
FileSizeHigh:LongWord;
iSize:integer;
begin
try
hFile := CreateFile(PChar(LogFile),GENERIC_READ,FILE_SHARE_READ,nil,OPEN_EXISTING,FILE_ATTRIBUTE_NORMAL,0);
iSize := GetFileSize(hFile,@FileSizeHigh);
ResponseHttpHeader(LogFile,iSize); //send http header
CloseHandle(hFile);
WebApplication.SendFile(LogFile,false,'','');
except
Abort;
end;
end;我下载下来的文件所有的内容都被intraweb给修改了,内容如下:<HTML><HEAD><TITLE></TITLE><meta http-equiv="cache-control" con_tent="no-cache">
<meta http-equiv="pragma" con_tent="no-cache">
<NOSCRIPT><HTML><BODY>Your browser does not seem to support JavaScript. Please make sure it is supported and activated</BODY></HTML></NOSCRIPT>
<SCRIPT>
var ie4 = (document.all)? true:false;
var ns6 = (document.getElementById)? true && !ie4:false;
function Initialize() {
var lWidth;
var lHeight;
if (ns6) {
lWidth = window.innerWidth - 30;
lHeight = window.innerHeight - 30;
} else {
lWidth = document.body.clientWidth;
lHeight = document.body.clientHeight;
}
document.forms[0].elements["IW_width"].value = lWidth;
document.forms[0].elements["IW_height"].value = lHeight;
document.forms[0].submit();
}</SCRIPT></HEAD><BODY on_load="Initialize()">
<form method=post action="">
<input type=hidden name="IW_width">
<input type=hidden name="IW_height">
<input type=hidden name="IW_SessionID_" value="016r1cy29408l6swg16r1cyvn1">
<input type=hidden name="IW_TrackID_" value="0">
</form></BODY></HTML>请问大家,我改怎么办啊?????????急死我了
解决方案 »
免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货