【问题标题】:cocoahttpserver - disaply filecocoahttpserver - 显示文件
【发布时间】:2013-10-19 12:49:07
【问题描述】:

我尝试使用 cocoaHttpServer 通过 pc/mac 浏览器显示我的文档的文件夹文件,我使用 iPhoneHTTPServer 示例,我更改了根目录但我没有看到任何文件。 这是我的代码:

[DDLog addLogger:[DDTTYLogger sharedInstance]];
httpServer = [[HTTPServer alloc] init];     
[httpServer setType:@"_http._tcp."];
NSArray *documentPaths = NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES);
NSString *documentsDir = [documentPaths objectAtIndex:0];
[httpServer setDocumentRoot:documentsDir];
[self startServer];

我需要创建一个索引文件?但在这种情况下,我需要从设备而不是浏览器刷新索引内容...有什么提示吗?

【问题讨论】:

    标签: share nsdocumentdirectory cocoahttpserver


    【解决方案1】:

    index.html 文件:

    <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd">
    <html>
        <head>
            <meta http-equiv=\"content-type\" content=\"text/html; charset=UTF-8\">
                <title>DPFileUpload</title>
                </head>
        <body>
            <form action="upload.html" method="post" enctype="multipart/form-data" accept-charset="utf-8"> Select a file to upload :
                <input type="file" name="upload1"><br/> <br/>
                    <input type="submit" value="Submit"> 
                        </form>
    
    
        </body>
    </html>
    

    upload.html 文件:

    <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd">
    <html>
        <head>
            <meta http-equiv=\"content-type\" content=\"text/html; charset=UTF-8\">
                </head>
        <body>
            %MyFiles%
        </body>
    </html>
    

    这些需要在您的网络服务器文档目录中。 我还没有找到增强它的方法(看起来更好)并且只提供了一个基本的实现。至少可以工作。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2011-07-13
      • 1970-01-01
      相关资源
      最近更新 更多