如何在iOS的ftp服务器上上传.png或.jpg图像?
问题描述:
我想从我的iOS应用程序将图像上传或保存到FTP服务器.但是每次我收到 ftp未连接
I want to upload or save image to FTP server from my iOS app. but every time I get error that ftp not connected
我使用SCRFTPRequest库.
I use SCRFTPRequest library.
这是我的代码...
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];
答
最后,我成功将图像文件上传到ftp服务器上.
Finally i got success to upload image file on ftp server.
要在ftp上上传图像,我使用了Gold Raccoon外部库.有了这个库,您可以轻松地将图像上传到ftp服务器.
To upload image on ftp i used Gold Raccoon external library.with this library you can easily upload image to ftp server.