我正在编写一个客户机-服务器程序,用于从Mac桌面上的某个位置选择一个文件,然后将其复制到iPhone模拟器中。然后,它将使用TCP协议将其上传到服务器。
谁可以建议如何做,或可以建议一个网站,我可以了解它。我在网上得到了下面的代码,它会执行上面要求的任务吗?
if ( [[NSFileManager defaultManager] isReadableFileAtPath:source] )
[[NSFileManager defaultManager] copyPath:source toPath:destination handler:nil];
[[NSWorkspace sharedWorkspace] performFileOperation:NSWorkspaceRecycleOperation source:foldername destination:@"" files:filenamesArray tag:&tag];发布于 2011-05-24 00:29:23
看看ASIHTTPRequest:http://allseeing-i.com/ASIHTTPRequest/
下面是我使用ASIHTTPRequest上传文件的一段代码。
ASIFormDataRequest *request = [ASIFormDataRequest requestWithURL:url];
[request addPostValue:token forKey:@"token"];
[request setFile:recorderFilePath forKey:@"thefile"];
[request startSynchronous];请注意,变量recorderFilePath是音频文件的路径,这是我在app文档目录中创建的文件,将以下代码添加到您的头文件中,将帮助您获取文档目录。
#define DOCUMENTS_FOLDER [NSHomeDirectory() stringByAppendingPathComponent:@"Documents"]https://stackoverflow.com/questions/6068409
复制相似问题