开发者

image upload on server

I am trying to uploa开发者_高级运维d an image to server using iphone . I haven't done it before.

But I am not getting how can i do it.

I know how to add text data on server.

But how to add the image data or an Image to server . Can any one suggest!?


Try this .

How to upload an image in iPhone application

and this

How can I upload a photo to a server with the iPhone?

EDIT:

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

Also check out the video : http://www.youtube.com/watch?v=aQXaJO36I7Y

The kid is explaining the things pretty easily .you can do the thing with that video .

You will also need a php script to parse the image at server side .

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜