【发布时间】:2014-03-31 06:00:56
【问题描述】:
我想从我的 iOS 应用程序上传或保存图像到 FTP 服务器。但每次我收到 ftp not connected
的错误我使用 SCRFTPRequest 库。
这是我的代码...
UIImage *image = [info objectForKey:@"UIImagePickerControllerOriginalImage"];
NSData * imageData = UIImagePNGRepresentation(image);
NSFileManager * fileManager = [NSFileManager defaultManager];
NSArray * paths = NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES);
NSString * documentsDirectory = [paths objectAtIndex:0];
NSString *fullPath = [documentsDirectory stringByAppendingPathComponent:[NSString stringWithFormat:@"%@.png",image]];
[fileManager createFileAtPath:fullPath contents:imageData attributes:nil];
NSLog(@"image saved");
[picker dismissViewControllerAnimated:YES completion:nil];
ftpRequest = [SCRFTPRequest requestWithURL:[NSURL URLWithString:@"ftp://myURL"] toUploadFile:fullPath];
ftpRequest.username = @"DemoUser";
ftpRequest.password = @"DemoUser";
ftpRequest.customUploadFileName = @"inapp";
ftpRequest.delegate = self;
[ftpRequest startAsynchronous];
【问题讨论】:
-
您可以使用QueueFTP。
-
@HimanshuJoshi 在你的链接中有一个 php 链接要指定,但我不知道它请帮我解决。
-
我不知道
CFUrl