[英]Browse PDF file from iPhone and Upload on server
In my application I need to allow the user to browse some PDF files from iPhone and upload one to a server. 在我的应用程序中,我需要允许用户从iPhone浏览一些PDF文件并将其上传到服务器。
I know how to upload a PDF file on a server, but I don't know how can I browse for PDF files. 我知道如何在服务器上上传PDF文件,但是我不知道如何浏览PDF文件。
Please help me. 请帮我。
You can only view files in that your App's sandbox. 您只能在该应用的沙箱中查看文件。 Every App has got a Documents, Cache and temp folders. 每个应用程序都有一个文档,缓存和临时文件夹。
sample code : 示例代码:
NSError *err = nil;
NSArray *myPathList = NSSearchPathForDirectoriesInDomains(NSCachesDirectory, NSUserDomainMask, YES);
NSString *myPath = [myPathList objectAtIndex:0];
NSArray *dirContent = [[NSFileManager defaultManager] contentsOfDirectoryAtPath:myPath error:&err];
if(err) NSLog(@"ERROR: %@",[err localizedDescription]);
NSMutableArray *filePaths = nil;
int count = (int)[dirContent count];
for(int i=0; i<count; i++)
{
[filePaths addObject:[dirContent objectAtIndex:i]];
}
return filePaths;
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.