没有数据到达服务器

时间:2012-06-18 12:16:19

标签: ios upload asihttprequest

我正在尝试将图像和文档上传到远程服务器。远程服务器具有用于处理uploads的PHP页面。请求成功发送但没有任何内容到达服务器。我正在使用ASIHTTPREQUEST。这是代码:

-(void)uploadFile
{
    NSString *resume =@"0";
    NSUserDefaults *userCredentials =[NSUserDefaults standardUserDefaults];
    NSString *userName =[userCredentials objectForKey:@"userName"];
    NSLog(@"Media Type : %@",selectedMediaType);
    NSLog(@"User Name : %@",[userCredentials objectForKey:@"userName"]);
    NSLog(@"File Name : %@",delegate.fileName);
    NSString *stringToAppend =[NSString stringWithFormat:@"mediatype=%@&file_name=%@&usrname=%@&filesize=%@&sha256sum=%@&resume=%@",selectedMediaType,delegate.fileName,userName,fileSize,fileSHA256Sum,resume];
    NSURL *url = [NSURL URLWithString:[NSString stringWithFormat:@"http://briareos.code20.com/putmedia.php?%@",stringToAppend ]];
    uploadMedia = [ASIHTTPRequest requestWithURL:url];
    NSLog(@"URL WITH INFO %@",url);
    [uploadMedia appendPostData:dataToUpload];
    [uploadMedia setDelegate:self];
    [uploadMedia setRequestMethod:@"PUT"];
    [uploadMedia startAsynchronous];

}

有人能让我知道可能是什么问题吗?

1 个答案:

答案 0 :(得分:0)

有错误吗?尝试追加

NSError *error = [uploadMedia error];
if (!error) {
    NSString *response = [uploadMedia responseString];
} else {
    // catch your error here
}

代码