2012-06-04 81 views

回答

8

TIdHTTP具有Post()兩個重載版本的將文件名作爲輸入:

var 
    Response: String; 

Response := IdHTTP1.Post('https://www.example.com/ex/exampleAPI.asmx/Process', 'c:\filename.txt'); 

var 
    Response: TStream; 

Response := TMemoryStream.Create; 
IdHTTP1.Post('https://www.example.com/ex/exampleAPI.asmx/Process', 'c:\filename.txt', Response); 
... 
Response.Free; 

注意您發佈到HTTPS URL,那麼您需要首先分配啓用SSL的IOHandler,如TIdSSLIOHandlerSocketOpenSSL,到TIdHTTP.IOHandler財產事前。

+0

謝謝,但是當我嘗試編譯時出現以下錯誤。 「E2250」Post「沒有過載的版本,可以用這些參數調用」任何想法? – Trevor

+1

然後你沒有使用最新版本的Indy,因爲當前版本確實有這樣的重載:'函數Post(AURL:string; const ASourceFile:String {$ IFDEF STRING_IS_ANSI}; ADestEncoding:TIdTextEncoding = nil { $ ENDIF}):string;過載;'和'過程(AURL:string; const ASourceFile:String; AResponseContent:TStream);超負荷;' –

+0

好吧我試圖更新Indy,但它的痛苦我有很多麻煩。我以前從來沒有安裝過軟件包。有沒有辦法用TWebBrowser偶爾做到這一點? – Trevor