【问题标题】:Browse PDF file from iPhone and Upload on server从 iPhone 浏览 PDF 文件并上传到服务器
【发布时间】:2015-04-01 06:33:22
【问题描述】:

在我的应用程序中,我需要允许用户从 iPhone 浏览一些 PDF 文件并将其上传到服务器。
我知道如何在服务器上上传 PDF 文件,但我不知道如何浏览 PDF 文件。

请帮帮我。

【问题讨论】:

    标签: ios objective-c iphone file-upload


    【解决方案1】:

    您只能查看您应用的沙箱中的文件。每个应用程序都有一个 Documents、Cache 和 temp 文件夹。

    示例代码:

    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;
    

    【讨论】:

    • 非常感谢您的回复。我想浏览 PDf 文件并允许用户选择和上传。我已经实现了图像,但我没有找到任何 PDf 文件的解决方案。
    • 正如我所提到的,您只能从应用程序的沙箱中访问文件。无法像对 iPhone 画廊中的图片那样列出 pdf。
    猜你喜欢
    • 2020-06-20
    • 1970-01-01
    • 2017-01-14
    • 1970-01-01
    • 1970-01-01
    • 2019-05-16
    • 2012-09-11
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多