2015-08-29 199 views
1

我在ftp服務器上有多個圖像上傳的問題,我用這個類文件「GoldRaccoon」只上傳最後一張圖片,,我想上傳所有圖片如何上傳多個圖片在ios上的多個圖像上傳到FTP服務器

- (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

你可以在你的頭文件

@property (nonatomic, strong) GRRequestsManager *requestsManager; 

定義這麼做然後,你必須初始化與FTP服務器的名稱,用戶名密碼&您的請求管理器。

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

我只使用此方法..但它不是上傳多個圖像..它上傳最後一張圖片上載過程 –