sending .txt file to ftp

2019-06-05 19:53发布

问题:

I have managed (finally) to send something (a picture) to my server. This has been a painful journey for me.

I used the Apple sample code for SimpleFTPSample and put in my server details. I now want to do this again, but this time send a text file with the contents of whatever in entered into a textField.

Can anyone help?

回答1:

Here's a FTP library that works on iPhone:

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

The example on their web page looks straightforward:

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];


标签: iphone xcode ftp