有人可以帮助我发现有关将图像从iPhone上传到服务器的错误吗?

时间:2009-11-24 08:59:57

标签: iphone upload file-upload network-programming

我严格遵循How can I upload a photo to a server with the iPhone?的答案。

以下部分是按下按钮时调用的部分。

NSLog(@"buttonPressed: %@", [ConnectServerTryViewController getPathForFile: @"myPic.png"]);
[[EPUploader alloc] initWithURL:[NSURL URLWithString:@"http://10.27.8.251/senior/uploader.php"]
                       filePath: [ConnectServerTryViewController getPathForFile: @"myPic.png"] 
                       delegate:self
                   doneSelector:@selector(onUploadDone:)
                  errorSelector:@selector(onUploadError:)];

这是我的ConnectServerTryViewController类的静态getPathForFile方法:

+ (NSString*) getPathForFile: (NSString*) st{
    NSString * path = [[NSBundle mainBundle] bundlePath];
    NSString * finalPath = [path stringByAppendingPathComponent: st];
    return finalPath;   
}

我非常确定我的php是正确的。我可以毫无问题地将图像从我的mac上传到我的服务器,但下面显示了XCode控制台的输出:

2009-11-24 15:43:31.177 ConnectServerTry[1645:20b] buttonPressed: /Users/myName/Library/Application Support/iPhone Simulator/User/Applications/4127CEB7-EFCA-4D84-B7CF-F78ED871A499/ConnectServerTry.app/myPic.png
2009-11-24 15:43:31.179 ConnectServerTry[1645:20b] Begin upload method
2009-11-24 15:43:31.180 ConnectServerTry[1645:20b] Trying urlRequest
2009-11-24 15:43:31.181 ConnectServerTry[1645:20b] Trying connection
2009-11-24 15:43:31.188 ConnectServerTry[1645:20b] Now, wait for the URL connection to call us back.
2009-11-24 15:43:33.781 ConnectServerTry[1645:20b] -[EPUploader(Private) connection:didReceiveResponse:]: self:0x0x3d19760

[Session started at 2009-11-24 15:43:33 +0700.]
2009-11-24 15:43:33.781 ConnectServerTry[1645:20b] -[EPUploader(Private) connection:didReceiveData:]: self:0x0x3d19760
2009-11-24 15:43:33.783 ConnectServerTry[1645:20b] -[EPUploader(Private) connection:didReceiveData:]: data: C:\AppServ\www\senior
There was an error uploading the file, please try again!
2009-11-24 15:43:33.784 ConnectServerTry[1645:20b] -[EPUploader(Private) connectionDidFinishLoading:]: self:0x0x3d19760
2009-11-24 15:43:33.784 ConnectServerTry[1645:20b] *** -[ConnectServerTryViewController onUploadError:]: unrecognized selector sent to instance 0x3d21c70
2009-11-24 15:43:33.785 ConnectServerTry[1645:20b] *** Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: '*** -[ConnectServerTryViewController onUploadError:]: unrecognized selector sent to instance 0x3d21c70'
2009-11-24 15:43:33.785 ConnectServerTry[1645:20b] Stack: (
    8307803,
    2435731003,
    8689723,
    8259190,
    8111810,
    12403,
    12513,
    3020196,
    3020051,
    13428152,
    13426200,
    13426914,
    13426914,
    13429398,
    13088725,
    8091873,
    8088648,
    87949,
    88146,
    23633923,
    8304
)

您是否知道这里可能存在哪些错误?

非常感谢。

1 个答案:

答案 0 :(得分:1)

onUploadError:是ConnectServerTryViewController上的无效选择器。如何定义onUploadError,它是否在ConnectServerTryViewController类中定义?