【问题标题】:Iphone Upload String to FTP serverIphone 上传字符串到 FTP 服务器
【发布时间】:2012-04-04 22:15:08
【问题描述】:

我需要简单地将一个字符串作为 txt 上传到我的 ftp 服务器,我搜索得很好,但没有任何效果。有没有简单地将字符串上传到 ftp 服务器? 注意:我查看了 s7ftp 的东西 simpleftp 和苹果的 ftp 东西,我无法得到任何工作。

提前致谢。

【问题讨论】:

    标签: iphone ios5


    【解决方案1】:

    你能创建一个服务器端脚本来解析一个 POST/GET 字符串吗?对于您可以在 3 行服务器端执行的操作,似乎上传文件可能需要大量繁重的工作/编码。只是一个想法。

    编辑添加

    这里有一些简单的 Objective-C 供你参考:

    // Create the request.
    NSURLRequest *theRequest=[NSURLRequest requestWithURL:[NSURL URLWithString:@"http://www.YOURDOMAIN.com/?string=YOURSTRINGORWHATEVER"]
                            cachePolicy:NSURLRequestUseProtocolCachePolicy
                        timeoutInterval:60.0];
    // create the connection with the request
    // and start loading the data
    NSURLConnection *theConnection=[[NSURLConnection alloc] initWithRequest:theRequest delegate:self];
    if (theConnection) {
        // Create the NSMutableData to hold the received data.
        // receivedData is an instance variable declared elsewhere.
        receivedData = [[NSMutableData data] retain];
    } else {
        // Inform the user that the connection failed.
    }
    

    Click here for more info on URL Loading

    如果您无法使用 ARC 或遇到问题,请尝试此课程。很方便:

    SMWebRequest Class on GitHub

    希望这会有所帮助。

    【讨论】:

    • 这正是我会做的。在 PHP 中使用 $_GET 变量非常容易。
    • 我什至不能按原样发送字符串。
    • 好的,我可以做一个服务器端代码,但我不能向服务器发送任何东西。有什么想法???
    • ARC 禁止发送“保留”的显式消息 它给了我这个错误。
    • 谢谢,但 SMWebRequest 与我的情况无关。
    猜你喜欢
    • 1970-01-01
    • 2017-01-06
    • 1970-01-01
    • 2010-11-18
    • 2011-11-14
    • 2011-09-19
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多