我正在使用此代码在服务器上上传图片..但作为回应我从我的网络服务获得此响应。为foreach()提供的参数无效
-(IBAction)uploadToServer:(id)sender {
NSString *videoURL = [[NSBundle mainBundle] pathForResource:@"1" ofType:@"jpeg"];
NSData *videoData = [NSData dataWithContentsOfURL:[NSURL fileURLWithPath: videoURL]];
AFHTTPClient *httpClient = [AFHTTPClient clientWithBaseURL:[NSURL URLWithString:@"http://youngdecade.com/test3/"]];
NSMutableURLRequest *request = [httpClient multipartFormRequestWithMethod:@"POST" path:@"uploadmultipleimage.php" parameters:nil constructingBodyWithBlock:^(id <AFMultipartFormData>formData)
{
[formData appendPartWithFileData:videoData name:@"file" fileName:@"1.jpeg" mimeType:@"image/jpeg"];
}];
AFHTTPRequestOperation *operation = [[AFHTTPRequestOperation alloc] initWithRequest: request];
[operation
setCompletionBlockWithSuccess:^(AFHTTPRequestOperation *operation, id responseObject) {
NSLog(@"response string=%@",operation.responseString);
}
failure:^(AFHTTPRequestOperation *operation, NSError *error) {
NSLog(@"Error : %@", operation.responseString);
}
];
[operation start];
}
uploadmultipleimage.php:
<html lang="en">
<head>
<meta charset="UTF-8" />
<title>Multiple File Ppload with PHP</title>
</head>
<body>
<form action="uploadmultipleimage.php" method="post" enctype="multipart/form-data">
<input type="file" id="file" name="file[]" multiple="multiple" accept="image/*" />
<input type="submit" value="Upload!" />
</form>
</body>
</html>