Iupfile接口应该是这个样子:  Iupfile = interface(IDispatch)
    ['{5C40D0EB-5A22-4A1E-8808-62207AE04B51}']
    procedure OnStartPage(const AScriptingContext: IUnknown); safecall;
    procedure OnEndPage; safecall;
    function  Get_Form(Formname: OleVariant): OleVariant; safecall;
    function  Get_FileName: OleVariant; safecall;
    function  Get_FileSize: Integer; safecall;
    procedure FileSaveAs(FileName: OleVariant); safecall;
    function  Get_FileData: OleVariant; safecall;
    function  Get_FileType: OleVariant; safecall;
    property Form[Formname: OleVariant]: OleVariant read Get_Form;
    property FileName: OleVariant read Get_FileName;
    property FileSize: Integer read Get_FileSize;
    property FileData: OleVariant read Get_FileData;
    property FileType: OleVariant read Get_FileType;
  end;Tupfile类的声明如下:  Tupfile = class(TASPObject, Iupfile)
  public
  protected
    procedure OnEndPage; safecall;  //页面开始 
    procedure OnStartPage(const AScriptingContext: IUnknown); safecall;  //页面
结束
    procedure FileSaveAs(Filename: OleVariant); safecall;  //保存文件
    function Get_Form(Formname: OleVariant): OleVariant; safecall;  //
    function Get_FileName: OleVariant; safecall;  
    function Get_FileSize: Integer; safecall;
    function Get_FileData: OleVariant; safecall;
    function Get_FileType: OleVariant; safecall;
  private
    FContentData:string;
    FFileData,FFileName,FFileType:string;
    FFormInfo:TStringList;
    function instr(str1,str2:string;startpos:integer):integer;
    procedure AnalyFormData(content:string);
  end;
procedure Tupfile.OnStartPage(const AScriptingContext: IUnknown);
var
  AOleVariant : OleVariant;
  tmpvar : OleVariant;
  contentlength : integer;
  i,DeliCount,pos1,pos2,lastpos : integer;
  FDelimeter : string;
begin
  inherited OnStartPage(AScriptingContext);
  FFormInfo := TStringList.Create;  contentlength := Request.TotalBytes;
  AOleVariant := contentlength;
  tmpvar := Request.BinaryRead(AOleVariant);
  for i := 1 to contentlength -1 do
  begin
    FContentData := FContentData + chr(byte(tmpvar[i]));
  end;  pos1 := pos(#13#10,FContentData);
  FDelimeter := copy(FContentData,1,pos1+1);
  DeliCount := length(FDelimeter);
  lastpos := 1;  pos1:=0;
  while pos2>=pos1 do
  begin
    pos1 := instr(FDelimeter,FContentData,lastpos);
    if pos1 = 0 then Break;
    pos1 := pos1 + DeliCount;
    pos2 := instr(FDelimeter,FContentData,pos1)-1;
    AnalyFormData(copy(FContentData,pos1,pos2-pos1-1));
    lastpos := pos2;
  end;
end;procedure Tupfile.AnalyFormData(content: string);
var
  pos1,pos2:integer;
  FormName,FormValue:string;
  isFile:boolean;
begin
  isFile := false;
  pos1 := instr('name="',content,1)+6;
  pos2 := instr('"',content,pos1);
  FormName := copy(content,pos1,pos2-pos1);  //检查是否文件
  pos1 := instr('filename="',content,pos2+1);
  if pos1 <> 0 then
  begin
    isFile := true;
    pos1 := pos1 + 10;
    pos2 := instr('"',content,pos1);
    FFilename := copy(content,pos1,pos2-pos1);
  end;  pos1 := instr(#13#10#13#10,content,pos2+1)+4;
  FormValue := copy(content,pos1,length(content)-pos1);  if isfile then
  begin
    FFileData := FormValue;
    //查找文件类型信息
    pos2 := instr('Content-Type: ',content,pos2+1);
    if pos2 <> 0 then
    begin
      pos2 := pos2 + 14;
      FFileType := copy(content,pos2,pos1-4-pos2);
    end;
  end
  else
  begin
  FFormInfo.add(FormName+'='+FormValue);
  end;
end;  
function Tupfile.Get_Form(Formname: OleVariant): OleVariant;
begin
    Result := FFormInfo.Values[Formname];
end;
function Tupfile.Get_FileName: OleVariant;
begin
  Result := ExtractFileName(FFileName);
end;
function Tupfile.Get_FileSize: Integer;
begin
  Result := length(FFileData);
end;function Tupfile.Get_FileData: OleVariant;
var
  i:integer;
begin
  Result := VarArrayCreate( [0,length(FFileData)], varByte );
  for i := 0 to length(FFileData)-1 do
  begin
    Result[i] := Byte(FFileData[i+1]);
  end;
end;  这三个函数分别返回文件的名称、大小、数据。要注意的是,在返回文件数据时,必须进行相应的转
换,将Delphi中的string类型转换为OleVariant类型。
  
procedure Tupfile.FileSaveAs(Filename: OleVariant);
var
  fsout:TFileStream;
  i:integer;
  afile:file of byte;
begin
  fsout := TFileStream.Create(Filename,fmcreate);
  for i := 1 to length(FFileData) do
  begin
    fsout.Write(Byte(FFileData[i]),1)
  end;
  fsout.Free;
end;
你试一试