我在ftp服务器上的多个图片上传时遇到问题,我已经使用过这个类文件" GoldRaccoon"它只上传最后一张图片,我想上传所有图片如何上传多张图片
- (void)zcImagePickerController:(ZCImagePickerController *)imagePickerController didFinishPickingMediaWithInfo:(NSArray *)info {
[self dismissPickerView];
NSString *fullPath;
for (NSDictionary *imageDic in info) {
UIImageView *imageView = [[UIImageView alloc] initWithImage:[imageDic objectForKey:UIImagePickerControllerOriginalImage]];
imageView.contentMode = UIViewContentModeScaleAspectFit;
[arrImageView addObject:imageView];
UIImage *image1 = [imageDic objectForKey:@"UIImagePickerControllerOriginalImage"];
NSData * imageData1 = UIImageJPEGRepresentation(image1,100); //convert image into .png format.
NSFileManager * fileManager = [NSFileManager defaultManager];//create instance of NSFileManager
NSArray * paths1 = NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES); //create an array and store result of our search for the documents directory in it
NSString * documentsDirectory = [paths1 objectAtIndex:0]; //create NSString object, that holds our exact path to the documents directory
fullPath = [documentsDirectory stringByAppendingPathComponent:[NSString stringWithFormat:@"%@.jpg",image1]]; //add our image to the path
// NSString *str=[NSString stringWithFormat:@"%@.jpg",image1];
[fileManager createFileAtPath:fullPath contents:imageData1 attributes:nil]; //finally save the image
[arrvalue addObject:fullPath];
NSURL *imageURL = [imageDic valueForKey:UIImagePickerControllerReferenceURL];
ALAssetsLibraryAssetForURLResultBlock resultblock =^(ALAsset *myasset)
{
ALAssetRepresentation *representation = [myasset defaultRepresentation];
NSString *fileName = [representation filename];
// Send WebService
// [arrName addObject:fileName];
[self sendImage:fileName :fullPath];
};
ALAssetsLibrary* assetslibrary = [[ALAssetsLibrary alloc] init] ;
[assetslibrary assetForURL:imageURL resultBlock:resultblock failureBlock:nil];
}
}
答案 0 :(得分:0)
您可以通过在头文件中定义
来实现@property (nonatomic, strong) GRRequestsManager *requestsManager;
然后,您必须使用ftp服务器名称,用户名和&amp ;;初始化您的请求管理器。密码。
self.requestsManager = [[GRRequestsManager alloc] initWithHostname:@"ftp://xxxxxx.com/xxxxx/"
user:@"User"
password:@"#&*DKJD%^"];
self.requestsManager.delegate = self;
然后添加图片
[self.requestsManager addRequestForUploadFileAtLocalPath:fileName toRemotePath:fullPath];
最后,您开始上传流程
[self.requestsManager startProcessingRequests];