iPhone +文件上传控件

时间:2009-11-20 09:46:33

标签: iphone cocoa-touch file upload controls

我有一个将文件从iPhone上传到网络服务器的应用程序。

问题是我想给用户一个控件,他们可以从中选择文件/照片,然后将其上传到服务器上。

任何人都可以帮助我

2 个答案:

答案 0 :(得分:1)

我认为您想使用作为系统组件的ImagePickerController来允许用户选择照片。

答案 1 :(得分:1)

您可以将UIImage内容作为包装在NSData中的JPEG或PNG:

NSData *data = UIImageJPEGRepresentation(image, 1);
if( data ) {  // it's possible nil may be returned
    ;// do stuff here. 
    // see: link to other answer on SO below.
    // if you want to write to file, try:
    [data writeToFile:filePath atomically:YES];
}

File Upload to HTTP server in iphone programming