I am implementing a file upload function similar to the PostDataDemo (
https://github.com/Atozed/IntraWeb/tree/...stDataDemo) and is working fine. However, I am wondering if there is a way to extract the filename in the ContentHandler? The aRequest.File object only contains the temporary filename (.tmp) and not the original filename.
Within the content handler you have various information about the file, not only the temporary file name.
Here is the code form that example:
Code:
function TContentXML.Execute(aRequest: THttpRequest; aReply: THttpReply; const aPathname: string; aSession: TIWApplication;
aParams: TStrings): boolean;
var
xFile: THttpFile;
xml: string;
begin
Result := False;
if aRequest.Files.Count = 1 then begin
xFile := THttpFile(aRequest.Files[0]);
xml := TIWTextFileReader.ReadAllText(xFile.TempPathName);
aReply.WriteString(ClassName + '.Execute - Content received: ' + xml);
Result := True;
end;
end;
These are the properties that you can get from the "xFile" variable above:
property FileName: TFileName;
property TempPathName: TFileName;
property ContentType: string;
property FileSize: Int64;
property FieldName: string;
property FileSize_WebApi: Int64;
property LastModified_WebApi: TDateTime;
property MIMEType_WebApi: string;
The _WebApi suffixed properties may or may not be available (it depends on the browser).