我有一個簡單的DataSnap REST服務器,在TWebModule上我添加了一個操作來偵聽路徑「/ upload_file」上的POST請求。 在的OnAction事件中,我有這樣的代碼:TWebResponse不解析我發佈的文件
procedure TWebModule.WebModulePostFileAction(Sender: TObject;
Request: TWebRequest; Response: TWebResponse; var Handled: Boolean);
var i: Integer;
str: String;
begin
for i :=0 to Request.Files.Count-1 do
Begin
Str:= Str +','+ Request.Files.Items[i].FileName;
// I will like to save or move the uploaded file to i.e. c:\myFiles\
End;
Response.Content:= Str;
end;
Request.Files.Count始終爲0,但是當我檢查Request.content對象,我可以看到多文件內容。我如何從請求中獲取發佈的文件?並將其保存在磁盤中的某處。從那裏我爲張貼的樣子
我的HTML表單:
<form action="/upload_file" method="POST" enctype="multipart/form-data">
Notes: <input type="text" name="notes"/>
File: <input type="file" name="my_file"/>
<input type="submit" value="Submit">
</form>
不幸的是,關於這個主題沒有太多的信息,我一直在努力了幾個小時,但沒有成功,很多的事情。 在此先感謝。
xxm可以本地處理多部分/表單數據文件上傳,甚至還支持從其他請求讀取上傳進度:http://xxm.sourceforge.net/這裏有一個例子https://sourceforge.net/p/xxm/code/HEAD/tree/trunk/Delphi/demo2/09%20上傳%20Progress/ – 2013-03-21 19:20:56
不幸的是,我的項目使用了DataSnap,並且編寫了另一個應用程序來處理上傳,似乎增加了我現有的複雜性項目。謝謝你的建議。 – 2013-03-22 04:35:16