我正在尝试在 Delphi 7 Webbroker CGI 中接受文件上传。
我正在使用 Shiv Kumar 的 TMsMultipartParser,但 Chrome 遇到问题。我无法访问解析的数据(令人惊讶的是,资源管理器工作正常)。
这是我的代码:
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;
按照建议here https://stackoverflow.com/a/15386511,我尝试使用http://www.mrsoft.org/Delphi/MultipartParser.pas http://www.mrsoft.org/Delphi/MultipartParser.pas但我无法编译它。它使用一个名为 UniversalUtils 的单元,我在任何地方都找不到。
我知道这是一项非常过时的技术。几乎所有对它的引用都已经从网络上消失了(相信我,我已经搜索过)。购买任何帮助将不胜感激。
Thanks.
感谢@mrabat,我终于解决了我的问题。
这个项目开始于Delphi 5。后来升级到Delphi 7(无法进一步升级,因为很多部分不支持Unicode字符串,我们使用ANSI)。
我们使用 Shiv 的 TMsMultipartParser 因为 Delphi 5 没有包含任何解析器。
Delphi 7 在 ReqMulti.pas 单元中有 TMultipartContentParser,并且它工作得很好。
对于需要示例的任何人,我将发布我的工作代码:
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;
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)