0
NSString *urlName=@"url name"; 
NSLog(@"url %@",urlName);
NSURL *url=[NSURL URLWithString:urlName];

ASIFormDataRequest *request1=[ASIFormDataRequest requestWithURL:url];
[request1 setRequestMethod:@"POST"];
[request1 addPostValue:tokenName forKey:@"loginToken"];

[request1 setFile:savedImagePath forKey:@"file"];
[request1 setDelegate:self];  
[request1 startAsynchronous];

这里我传递了两个参数,一个是字符串,另一个是图像路径。

4

1 回答 1

1

您似乎正在尝试上传文件,但您这样做的方法不正确。

上传应该像这样完成:

    NSData *imageData = UIImageJPEGRepresentation([UIImage imageName:fileName])
    [request setData:imageData withFileName:fileName andContentType:@"image/jpeg" forKey:@"userfile"];
于 2012-11-07T13:30:58.200 回答