使用indy10的TidHttpServer控制元件自制web 檔案服務器, 可以下載確無法實作上傳功能, 接收到資料后不會決議, 拜托哪位提示一二,萬分感謝!!
原始碼片段:
Var
mm: array of Byte;
k: Integer;
...
begin
...
if ARequestInfo.PostStream=nil then begin
AResponseInfo.ContentText := UTF8Encode('上傳檔案失敗!');
AResponseInfo.ContentType :='text/html';
AResponseInfo.ContentEncoding := 'UTF-8';
AResponseInfo.CharSet := 'UTF-8';
end else begin
ARequestInfo.PostStream.Position := 0;
// 如何判斷文本和二進制的不同格式? 完全沒有思路, 暫時先假裝是二進制吧
setlength(mm, ARequestInfo.PostStream.size+4);
k := ARequestInfo.PostStream.ReadData(mm, ARequestInfo.PostStream.size);
//???????????????????????????????????????
//size 有長度 讀到mm中有內容 全是亂碼 然后不知道該如何處理了!!!!!!!!!!!!!!!!!!!!!!!!
// 拜托大家了......
end...
end;
網頁端html上傳陳述句:
<form action="/upload.asp?path=/upload" method="post" accept-charset="UTF-8" enctype="multipart/form-data"><input type="file" size="60" name="fileUpload" /><input type="submit" value="https://bbs.csdn.net/topics/上傳檔案" /></form>
uj5u.com熱心網友回復:
form post肯定是指定了地址的了,你這是/upload.asp服務端只要判斷ARequestInfo.URI是接受檔案的URI,就可以直接ARequestInfo.PostStream.SaveToFile 了
轉載請註明出處,本文鏈接:https://www.uj5u.com/houduan/37838.html
標籤:網絡通信/分布式開發
上一篇:求助解決高效讀、寫xlsx問題
