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
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];
You're overwriting request.file
, hence only the last one gets uploaded. You have to make individual requests for each file.
Or you could use [request addFile:(id)data withFileName:(NSString *)fileName andContentType:(NSString *)contentType forKey:(NSString *)key]
to send multiple files in one request.