C# 使用ASIFormDataRequest将图像上载到服务器

C# 使用ASIFormDataRequest将图像上载到服务器,c#,iphone,.net,objective-c,C#,Iphone,.net,Objective C,嗨,为我的iPhone应用程序构建服务,需要具有从用户获取图像的功能: 到目前为止,我使用此方法仅获取文本: string input = null; using (StreamReader sr = new StreamReader(Request.InputStream)) { input = sr.ReadToEnd(); } 我应该如何从帖子中获取图像 这是我从iphone应用程序发送图像的方式: imageRequest = [ASIFormDataRequest re

嗨,为我的iPhone应用程序构建服务,需要具有从用户获取图像的功能: 到目前为止,我使用此方法仅获取文本:

string input = null;

using (StreamReader sr = new StreamReader(Request.InputStream))
{
      input = sr.ReadToEnd();
}
我应该如何从帖子中获取图像

这是我从iphone应用程序发送图像的方式:

imageRequest = [ASIFormDataRequest requestWithURL:url];
[imageRequest addData:imageData withFileName:@"someFileName.jpeg" andContentType:@"image/jpeg" forKey:@"uploadedImage"];
[imageRequest setDelegate:self];
[imageRequest setRequestMethod:@"POST"];
[imageRequest startAsynchronous];

无法通过添加名为的图像上载图像。首先将UIImage对象转换为Base64编码字符串,然后将该字符串发送到服务器

从链接下载支持文件

他们使用这些方法

- (NSString*) stringFromImage:(UIImage*)image
{
    if(image){
        NSData *dataObj = UIImagePNGRepresentation(image);
        return [dataObj base64Encoding];
    } else {
        return @"";
    }
}

- (UIImage*) imageFromString:(NSString*)imageString
{
    NSData* imageData =[NSData dataWithBase64EncodedString:imageString];
    return [UIImage imageWithData: imageData];

}
还要检查此链接,查看Base64中的图像到字符串和字符串到图像的链接


这对你有帮助

,但我在ASIFormDataRequest中看到很多帖子,说可以使用AsiformKit中的ASINetworkQueue类发送数据。检查此链接,它将帮助您