Iphone 上载图像数组会出现问题(ASIHTTPRequest)

Iphone 上载图像数组会出现问题(ASIHTTPRequest),iphone,arrays,image,http,upload,Iphone,Arrays,Image,Http,Upload,我正在使用ASIHTTPRequest库通过Web服务发送多个图像。我有一个由2张图片组成的数组,我想发送它们。但是,只有最新的图像正在上载。我认为这是因为图像2覆盖了图像1,因为它们的名称相同 如何更改阵列中每个图像的名称,以便正确上载所有文件 这是我的密码 NSString* filename2 = [NSString stringWithFormat:@"image.jpeg", i]; NSString *strURL = @"www.thisismyurl.com"; ASIForm

我正在使用ASIHTTPRequest库通过Web服务发送多个图像。我有一个由2张图片组成的数组,我想发送它们。但是,只有最新的图像正在上载。我认为这是因为图像2覆盖了图像1,因为它们的名称相同

如何更改阵列中每个图像的名称,以便正确上载所有文件

这是我的密码

NSString* filename2 = [NSString stringWithFormat:@"image.jpeg", i];
NSString *strURL = @"www.thisismyurl.com"; 
ASIFormDataRequest *request = [ASIFormDataRequest requestWithURL:[NSURL URLWithString:strURL]];
[request setDelegate:self];
[request setPostValue:@"This is sample text..." forKey:@"text"];

for (int i = 0; i < [array count]; i++) {
    [request addData:[array objectAtIndex:i] withFileName:filename2  andContentType:@"image/jpeg" forKey:[NSString stringWithFormat:@"image%d", i + 1]];
}   
[request startAsynchronous];
NSString*filename2=[nsstringstringwithformat:@“image.jpeg”,i];
NSString*strURL=@“www.thismyurl.com”;
ASIFormDataRequest*request=[AsiformDataRequestRequestWithURL:[NSURL URLWithString:strURL]];
[请求setDelegate:self];
[请求setPostValue:@“这是示例文本…”forKey:@“文本”];
对于(int i=0;i<[数组计数];i++){
[请求添加数据:[array objectAtIndex:i],文件名:filename2,内容类型:@“image/jpeg”forKey:[NSString stringWithFormat:@“image%d”,i+1];
}   
[请求启动同步];
编辑

这是我到目前为止的代码。首先,我从我的文档目录调用我的图像->将其转换为NSData->将NSData放入数组->将数组放入“addData:request”中。我怎样才能在发布每幅图像时为其指定一个特定的名称

NSString *docDir2 = [NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES) objectAtIndex:0];
            NSString *pngFilePath2 = [NSString stringWithFormat:@"%@/foto2.jpeg",docDir2];
            UIImage *img2 = [[UIImage alloc] initWithContentsOfFile:pngFilePath2];
            NSData *imageData2 = UIImageJPEGRepresentation(img2,0.75);

            NSString *docDir3 = [NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES) objectAtIndex:0];
            NSString *pngFilePath3 = [NSString stringWithFormat:@"%@/foto3.jpeg",docDir3];
            UIImage *img3 = [[UIImage alloc] initWithContentsOfFile:pngFilePath3];
            NSData *imageData3 = UIImageJPEGRepresentation(img3, 0.75);

            [array addObject:imageData2];
            [array addObject:imageData3];

            [img2 release];
            [img3 release];

            if ([array count] > 0) {

                NSString *strURL = @"this is my url"; 
                ASIFormDataRequest *request = [ASIFormDataRequest requestWithURL:[NSURL URLWithString:strURL]];
                [request setDelegate:self];
                [request setPostValue:@"This is sample text..." forKey:@"text"];
                for (int i = 0; i < [array count]; i++) {

                    [request addData:[array objectAtIndex:i] withFileName:@"image.jpeg"  andContentType:@"image/jpeg" forKey:[NSString stringWithFormat:@"image%d", i + 1]];

                }   
                [request startAsynchronous];


            }
            else {
                UIAlertView *alertView = [[UIAlertView alloc]initWithTitle:@"Message" message:@"You have to make some pictures" delegate:nil cancelButtonTitle:@"Ok" otherButtonTitles:nil];
                [alertView show];
                [alertView release];
            }
NSString*docDir2=[NSSearchPathForDirectoriesInDomains(NSDocumentDirectory,NSUserDomainMask,YES)objectAtIndex:0];
NSString*pngFilePath2=[NSString stringWithFormat:@“%@/foto2.jpeg”,docDir2];
UIImage*img2=[[UIImage alloc]initWithContentsOfFile:pngFilePath2];
NSData*imageData2=UIImageJPEG表示法(img2,0.75);
NSString*docDir3=[NSSearchPathForDirectoriesInDomains(NSDocumentDirectory,NSUserDomainMask,YES)对象索引:0];
NSString*pngFilePath3=[NSString stringWithFormat:@“%@/foto3.jpeg”,docDir3];
UIImage*img3=[[UIImage alloc]initWithContentsOfFile:pngFilePath3];
NSData*imageData3=UIImageJPEG表示法(img3,0.75);
[数组addObject:imageData2];
[array addObject:imageData3];
[img2发布];
[img3发布];
如果([数组计数]>0){
NSString*strURL=@“这是我的url”;
ASIFormDataRequest*request=[AsiformDataRequestRequestWithURL:[NSURL URLWithString:strURL]];
[请求setDelegate:self];
[请求setPostValue:@“这是示例文本…”forKey:@“文本”];
对于(int i=0;i<[数组计数];i++){
[请求添加数据:[array objectAtIndex:i]的文件名:@“image.jpeg”和内容类型:@“image/jpeg”forKey:[NSString stringWithFormat:@“image%d”,i+1]];
}   
[请求启动同步];
}
否则{
UIAlertView*alertView=[[UIAlertView alloc]initWithTitle:@“消息”消息:@“您必须制作一些图片”代理:无取消按钮:@“确定”其他按钮:无];
[警报视图显示];
[警报视图发布];
}

您的文件名肯定是错的<代码>[NSString stringWithFormat:@“image.jpeg”,i]不是有效的格式

NSString *strURL = @"www.thisismyurl.com"; 
ASIFormDataRequest *request = [ASIFormDataRequest requestWithURL:[NSURL URLWithString:strURL]];
[request setDelegate:self];
[request setPostValue:@"This is sample text..." forKey:@"text"];

for (int i = 0; i < [array count]; i++) {

    [request addData:[array objectAtIndex:i] 
        withFileName:[NSString strinWithFormat:@"image_%d.jpg", i+1] 
      andContentType:@"image/jpeg" forKey:[NSString stringWithFormat:@"image%d", i + 1]];

 }   
[request startAsynchronous];
NSString*strURL=@“www.thismyurl.com”;
ASIFormDataRequest*request=[AsiformDataRequestRequestWithURL:[NSURL URLWithString:strURL]];
[请求setDelegate:self];
[请求setPostValue:@“这是示例文本…”forKey:@“文本”];
对于(int i=0;i<[数组计数];i++){
[请求添加数据:[数组对象索引:i]
withFileName:[NSString strinWithFormat:@“image_%d.jpg”,i+1]
andContentType:@“image/jpeg”forKey:[NSString stringWithFormat:@“image%d”,i+1]];
}   
[请求启动同步];

感谢您的回复,但它仍然不起作用(我将[request addData:[array objectAtIndex:I]替换为文件名:FileName 2和内容类型:@“image/jpeg”forKey:[NSString stringWithFormat:@“image%d”,I+1];->[request addData:[array objectAtIndex:I]替换为文件名:@“image.jpeg”和内容类型:@“image/jpeg”forKey:[NSString stringWithFormat:@“image%d”,i+1]];有什么线索吗?那么你再次引用了同一个文件名。我知道。这就是我的问题:-)woops,你的答案完成了任务。非常感谢vikingosegundo!数组中到底有什么?