Warning: file_get_contents(/data/phpspider/zhask/data//catemap/0/iphone/44.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Iphone 在服务器上上载图像_Iphone - Fatal编程技术网

Iphone 在服务器上上载图像

Iphone 在服务器上上载图像,iphone,Iphone,我正在尝试使用iphone将图像上传到服务器。 我以前没做过 但我不明白我该怎么做 我知道如何在服务器上添加文本数据 但如何将图像数据或图像添加到服务器。有人能建议吗 试试这个 还有这个 编辑: 另请观看视频: 这孩子很容易解释事情。你可以用视频来解释 您还需要一个php脚本来解析服务器端的图像 NSMutableURLRequest *urlRequest = [NSMutableURLRequest requestWithURL:url]; [urlRequest se

我正在尝试使用iphone将图像上传到服务器。 我以前没做过

但我不明白我该怎么做

我知道如何在服务器上添加文本数据

但如何将图像数据或图像添加到服务器。有人能建议吗

试试这个

还有这个

编辑:

另请观看视频:

这孩子很容易解释事情。你可以用视频来解释

您还需要一个php脚本来解析服务器端的图像

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];