本文介绍了Delphi 7 ISAPI WebBroker文件上传的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试在Delphi 7 Webbroker CGI中接受文件上传。

I am trying to accept file uploads in a Delphi 7 Webbroker CGI.

我正在使用Shiv Kumar的TMsMultipartParser,但Chrome出现问题。我无法访问已解析的数据(令人惊讶的是,资源管理器工作正常)。

I'm using Shiv Kumar's TMsMultipartParser, but I have a problem with Chrome. I can't access the parsed data (surprisingly, Explorer works fine).

这是我的代码:

with TMsMultipartFormParser.Create do
begin
    Parse(Request);

    lsExternalID:=ContentFields.Values['external_id'];

    if (lsExternalID='') then
        raise Exception.Create('No external ID');

    for i := 0 to Files.Count -1 do
    begin
        lsFileName:=files[i].FileName;
        //Rename file using external ID (not included for simplicity)
        Files[i].SaveToFile(lsFilename);
    end;
    Response.Content := 'OK';
    free;
end;

如建议在,我尝试使用,但我无法编译。它使用了一个我在任何地方都找不到的名为UniversalUtils的单元。

As suggested here, I tried to use http://www.mrsoft.org/Delphi/MultipartParser.pas but I can't compile it. It uses a unit called UniversalUtils that I can't find anywhere.

我知道这是一种非常过时的技术。几乎所有对它的引用都已从网上消失(相信我,我已经搜索过)。

I know this is a very obsolete technology. Almost all references to it have already disappeared from the web (believe me, I have searched). Buy any help would be deeply appreciated.

谢谢。

推荐答案

终于有了@mrabat,我终于解决了我的问题。
该项目始于Delphi5。后来被升级为Delphi 7(由于许多部分不支持Unicode字符串,因此无法使用,因此我们使用ANSI)。
我们使用Shiv的TMsMultipartParser是因为Delphi 5没有包含任何解析器。
Delphi 7在ReqMulti.pas单元中具有TMultipartContentParser,它可以正常工作。

I finally solved my problem, thanks to @mrabat.This project started in Delphi 5. It was later upgraded to Delphi 7 (it can't be upgraded further, because many parts can't support Unicode strings, we use ANSI).We were using Shiv's TMsMultipartParser because Delphi 5 didn't have any parser included.Delphi 7 has TMultipartContentParser in unit ReqMulti.pas, and it works perfectly.

对于需要示例的任何人,我都会发布我的工作代码:

For anyone that need an example, I'll post my working code:

with TMultipartContentParser.Create(Request) do
begin
    lsExternalID:=ContentFields.Values['external_id'];
    if (lsExternalID='') then
        raise Exception.Create('No external ID');

    for i := 0 to Request.Files.Count -1 do
    begin
        lsFileName:=Request.Files[i].FileName;
        //Rename file using external ID (not included for simplicity)
        TMemoryStream(Request.Files[i].Stream).SaveToFile(lsFilename);
    end;
    Response.Content := 'OK';
    Free;
end;

这篇关于Delphi 7 ISAPI WebBroker文件上传的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

07-25 08:21