Uploading images to server using ASIHTTPRequest in iphone

后端 未结 2 1192
梦如初夏
梦如初夏 2020-12-17 07:21

I have to upload images to server form iphone I am using ASIHTTPRequest for this. I have set a loop for uploading seven files. But after the executing only last file is uplo

2条回答
  •  有刺的猬
    2020-12-17 07:29

    You're overwriting the key called file & you need to use a queue.

    Do

    [self setNetworkQueue:[ASINetworkQueue queue]];
    [[self networkQueue] setDelegate:self];
    
    for (int i=1; i<8; i++) 
    {
        NSString* filename = [NSString stringWithFormat:@"Photo%d.jpg", i];
        NSString *path = [[NSHomeDirectory() stringByAppendingPathComponent:@"Documents"] stringByAppendingPathComponent:filename];
        [request setFile:path forKey:[NSString stringWithFormat:@"file%d", i]];
        [[self networkQueue] addOperation:request];
    }
    [[self networkQueue] go];
    

提交回复
热议问题