gpt4 book ai didi

iphone - 如何将图像发布到网络服务器

转载 作者:可可西里 更新时间:2023-11-01 04:26:39 24 4
gpt4 key购买 nike

我正在使用 json 解析处理 Web 服务。我可以从网络服务获取图片,有人可以帮我发布图片吗?我如何将图像发布到 Web 服务?

最佳答案

它会是这样的……

NSMutableURLRequest *mutableRequest = [[NSMutableURLRequest alloc] initWithURL:@"you url"];

[mutableRequest addValue:@"image/jpeg" forHTTPHeaderField: @"Content-Type"];

NSMutableData *body = [NSMutableData data];

[body appendData:[NSData dataWithData:UIImageJPEGRepresentation(self.image, 0.9)]];

[mutableRequest setHTTPBody:body];

NSURLResponse *response;
NSError *error;

(void) [NSURLConnection sendSynchronousRequest:mutableRequest returningResponse:&response error:&error];

谢谢

关于iphone - 如何将图像发布到网络服务器,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/13679009/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com