2011-03-15 189 views
1

我管理(最後)發送一些東西(圖片)到我的服務器。對我來說這是一個痛苦的旅程。發送.txt文件到ftp

我用蘋果示例代碼爲SimpleFTPSample,並把我的服務器的詳細信息。我現在想再次這樣做,但是這次發送一個文本文件,其中包含輸入到textField中的內容。

誰能幫助?

+0

如果你有一個很好的理由,用我不知道ftp(所以告訴我閉嘴,如果我是居高臨下)但是...爲什麼不使用Web服務方法?像任何其他HTTP數據上傳一樣發送POST數據?確保你已經通過FTP保護自己免受惡意攻擊。 – Joe 2011-03-15 14:36:11

回答

1

這裏有一個FTP庫,在iPhone上工作:

http://code.google.com/p/s7ftprequest/

他們的網頁上的例子看起來很簡單:

S7FTPRequest *ftpRequest = [[S7FTPRequest alloc] initWithURL: 
[NSURL URLWithString:@"ftp://192.168.1.101/"] 
toUploadFile:[[NSBundle mainBundle] pathForResource:@"Info" ofType:@"plist"]]; 

ftpRequest.username = @"testuser"; 
ftpRequest.password = @"testuser"; 

ftpRequest.delegate = self; 
ftpRequest.didFinishSelector = @selector(uploadFinished:); 
ftpRequest.didFailSelector = @selector(uploadFailed:); 
ftpRequest.willStartSelector = @selector(uploadWillStart:); 
ftpRequest.didChangeStatusSelector = @selector(requestStatusChanged:); 
ftpRequest.bytesWrittenSelector = @selector(uploadBytesWritten:); 

[ftpRequest startRequest];