-2

I want to upload image from UIImagePickerController.

I want to post my image to server from my iPad library.

I am not able to send the image to server. Any other options to do this?

I am doing this:

-(void)method_OpenImagePickerLibrary{

UIImagePickerController *picker = [[UIImagePickerController alloc] init];
picker.delegate = self;
picker.allowsEditing = YES;
picker.sourceType = UIImagePickerControllerSourceTypePhotoLibrary;

[self presentViewController:picker animated:YES completion:NULL];
}

-(void)imagePickerControllerDidCancel:(UIImagePickerController *)picker
{
[self dismissViewControllerAnimated:YES completion:nil];
}


-(void)imagePickerController:(UIImagePickerController *)picker didFinishPickingMediaWithInfo:(NSDictionary *)info
{
UIImage *image=[info objectForKey:UIImagePickerControllerEditedImage];
SelectPickerimageView.image=image;

NSData *imageData = UIImagePNGRepresentation(image);
NSString *documentsDirectory = [NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES) lastObject];
// Here is the file path for the image
filepath = [documentsDirectory stringByAppendingPathComponent:[NSString stringWithFormat:@"imagename.png"]];
[imageData writeToFile:filepath options:NSDataWritingAtomic error:nil];

[self dismissModalViewControllerAnimated:YES];
}

-(void)MethodUploadImage{

NSString *ftpUrl=@"ftp://yourftp Url";
NSString *strPortNumber=@"port Number";
NSString *strurlUpload=[NSString stringWithFormat:@"%@:%@",ftpUrl,strPortNumber];

NSString *getfilePath = filepath;
SCRFTPRequest *ftpRequest = [[SCRFTPRequest alloc] initWithURL:[NSURL URLWithString:strurlUpload] toUploadFile:getfilePath];
ftpRequest.username = @"Username";
ftpRequest.password = @"password";
ftpRequest.delegate = self;

/*  

ftpRequest.didFinishSelector = @selector(uploadFinished:);
ftpRequest.didFailSelector = @selector(uploadFailed:);
ftpRequest.willStartSelector = @selector(uploadWillStart:);
ftpRequest.didChangeStatusSelector = @selector(requestStatusChanged:);
ftpRequest.bytesWrittenSelector = @selector(uploadBytesWritten:);*/

[ftpRequest startRequest];
}

These commented lines are giving me errors

  • Error 1: Undeclared selector
  • Error 2: Property didFinishSelector,didFailSelector,willStartSelector,didChangeStatusSelector,bytesWrittenSelector not found on SCRFtprequest delegate

Any idea or suggestion would be highly welcome.

Kumar KL
  • 15,315
  • 9
  • 38
  • 60
Tina
  • 31
  • 1
  • 5
  • u can't directly stored in the image in server, u need to convert the UIimage to NSData, and NSdata to NSstring, the string is save or sent to the server, u get it the point – Anbu.Karthik Feb 03 '14 at 11:26

1 Answers1

0

Try using AFNetworking. It will surely make your life much easier.

gaurish.salunke
  • 1,059
  • 10
  • 18