【发布时间】:2013-10-07 11:02:38
【问题描述】:
如何将UIImage 或NSDate 转换为字节数组并发布到服务器。
在我的应用程序中,我必须将 UIImage 转换为字节数组,并且我必须发布。
对于我使用ASIFormDataRequest的帖子。
我的代码是:
NSUInteger len = [self.dataImage length];
Byte *byteData= (Byte*)malloc(len); //converting date to byte array
[self.dataImage getBytes:byteData length:len];
ASIFormDataRequest *request = [ASIFormDataRequest requestWithURL:[NSURL URLWithString:urlStr]];
[request setRequestMethod:@"POST"];
[request addData:self.dataImage withFileName:@"Image.png" andContentType:@"image/png" forKey:@"photo"];
[request setDelegate:self];
[request startAsynchronous];
【问题讨论】:
标签: ios post bytearray nsdata asiformdatarequest