如何在iOS的ftp服务器上上传.png或.jpg图像? [英] How to upload image either .png or .jpg on ftp server in ios.?

查看:268
本文介绍了如何在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.

https://github.com/albertodebortoli/GoldRaccoon

这篇关于如何在iOS的ftp服务器上上传.png或.jpg图像?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆