C
CoWo
Unregistered / Unconfirmed
GUEST, unregistred user!
如下方式实现文件下载:
procedure TWebModule1.WebModule1Action3Action(Sender: TObject;
Request: TWebRequest; Response: TWebResponse; var Handled: Boolean);
var
FileName:string;
S:TFileStream;
begin
FileName:=Request.QueryFields.Values['filename'];
if not(FileExists(FileName)) then
begin
Response.Content:=Banner_top.Content+'<br><br>The file'+
' you want to download doesn''t exist!'+Banner_foot.Content;
exit;
end
else
begin
S:=TFileStream.Create(FileName,fmOpenRead);
Response.ContentType:='file';
S.Position:=0;
Response.ContentStream:=S;
Response.SendResponse;
end;
end;
当客户端点击如下链接时:
http://127.0.0.1/scripts/fileadmin.dll/download?filename=C:/mpcsetup.log
客户端默认的下载文件名称却是:download.log,为什么呢?我如何让默认文件名称变为
mpcsetup.log呢?
不知道我表达的是不是清楚。
procedure TWebModule1.WebModule1Action3Action(Sender: TObject;
Request: TWebRequest; Response: TWebResponse; var Handled: Boolean);
var
FileName:string;
S:TFileStream;
begin
FileName:=Request.QueryFields.Values['filename'];
if not(FileExists(FileName)) then
begin
Response.Content:=Banner_top.Content+'<br><br>The file'+
' you want to download doesn''t exist!'+Banner_foot.Content;
exit;
end
else
begin
S:=TFileStream.Create(FileName,fmOpenRead);
Response.ContentType:='file';
S.Position:=0;
Response.ContentStream:=S;
Response.SendResponse;
end;
end;
当客户端点击如下链接时:
http://127.0.0.1/scripts/fileadmin.dll/download?filename=C:/mpcsetup.log
客户端默认的下载文件名称却是:download.log,为什么呢?我如何让默认文件名称变为
mpcsetup.log呢?
不知道我表达的是不是清楚。