Iphone 在服务器上上载图像
我正在尝试使用iphone将图像上传到服务器。 我以前没做过 但我不明白我该怎么做 我知道如何在服务器上添加文本数据 但如何将图像数据或图像添加到服务器。有人能建议吗 试试这个 还有这个 编辑: 另请观看视频: 这孩子很容易解释事情。你可以用视频来解释 您还需要一个php脚本来解析服务器端的图像Iphone 在服务器上上载图像,iphone,Iphone,我正在尝试使用iphone将图像上传到服务器。 我以前没做过 但我不明白我该怎么做 我知道如何在服务器上添加文本数据 但如何将图像数据或图像添加到服务器。有人能建议吗 试试这个 还有这个 编辑: 另请观看视频: 这孩子很容易解释事情。你可以用视频来解释 您还需要一个php脚本来解析服务器端的图像 NSMutableURLRequest *urlRequest = [NSMutableURLRequest requestWithURL:url]; [urlRequest se
NSMutableURLRequest *urlRequest =
[NSMutableURLRequest requestWithURL:url];
[urlRequest setHTTPMethod:@"POST"];
[urlRequest setValue:
[NSString stringWithFormat:@"multipart/form-data; boundary=%@", boundry]
forHTTPHeaderField:@"Content-Type"];
NSMutableData *postData =
[NSMutableData dataWithCapacity:[data length] + 512];
[postData appendData:
[[NSString stringWithFormat:@"--%@\r\n", boundry] dataUsingEncoding:NSUTF8StringEncoding]];
[postData appendData:
[[NSString stringWithFormat:
@"Content-Disposition: form-data; name=\"%@\"; filename=\"file.bin\"\r\n\r\n", FORM_FLE_INPUT]
dataUsingEncoding:NSUTF8StringEncoding]];
[postData appendData:data];
[postData appendData:
[[NSString stringWithFormat:@"\r\n--%@--\r\n", boundry] dataUsingEncoding:NSUTF8StringEncoding]];
[urlRequest setHTTPBody:postData];