将文件上传到ftp服务器时出现未知错误

时间:2012-10-04 08:05:27

标签: ios ftp

我正在尝试将图像文件上传到服务器。我正在应用https://github.com/valentinradu/WhiteRaccoon

中的示例

以下是代码:

    UIImage *image = [UIImage imageNamed:@"hotel1.jpg"];
    NSData *imageData = UIImageJPEGRepresentation(image, 0);

    WRRequestUpload * uploadImage = [[WRRequestUpload alloc] init];
    uploadImage.delegate = (id)self;

    //for anonymous login just leave the username and password nil
    uploadImage.hostname = @"***.***.***.***";
    uploadImage.username = @"-------";
    uploadImage.password = @"-------";

    //we set our data
    uploadImage.sentData = imageData;

    //the path needs to be absolute to the FTP root folder.
    //full URL would be ftp://xxx.xxx.xxx.xxx/space.jpg
    uploadImage.path = @"/android_images/image.jpg";

    //we start the request
    [uploadImage start];

但是它给出了错误 - [WRRequestListDirectory stream:handleEvent:] [Line 1004]未知错误!

我错过了什么。请帮帮我。

2 个答案:

答案 0 :(得分:1)

在uploadimage.hostname属性中尝试跳过ftp://部分并单独输入主机地址,例如:“qwerty.com”而不是“ftp://qwerty.com”,它为我解决了,并确保给出的验证详细信息是正确的。欢呼!!

答案 1 :(得分:0)

如果您使用的是BlackRaccoon,

请在BRRequest.m文件中进行一行更改。

- (id)initWithDelegate:(id<BRRequestDelegate>)aDelegate功能中。 改变

self.passiveMode = YES;

self.passiveMode = NO;

它会起作用....

这种改变对我有用。