网页端上传的方法如下:
<form enctype="multipart/form-data" action="upload.php" method="POST">
Send this file: <input name="fileUpload" type="file">
<input type="submit" name="action" value="UploadFile">
</form>
你参考下里面的参数 post的地址:http://www.xxx.com/sites/upload/upload.php
我的代码如下
// just testing
AFHTTPRequestOperationManager * httpManager = [[AFHTTPRequestOperationManager alloc] init];
httpManager.responseSerializer.acceptableContentTypes = [NSSet setWithObject:@"text/html"];
UIImage * testing = [UIImage imageNamed:@"testing"];
NSData * imageData = UIImagePNGRepresentation(testing);
NSDictionary *parameters = @{@"fileUpload": @"testing.png", @"action": @"UploadFile"};
[httpManager POST:@"http://www.xxx.com/sites/upload/upload.php"
parameters:parameters constructingBodyWithBlock:^(id<AFMultipartFormData> formData) {
[formData appendPartWithFormData:imageData name:@"image"];
} success:^(AFHTTPRequestOperation *operation, id responseObject) {
DDLogInfo(@"SUCCESSFULLY");
} failure:^(AFHTTPRequestOperation *operation, NSError *error) {
DDLogError(@"FAILURE : %@ --> %@", operation.responseString, error);
}];
哪位熟悉的帮忙看看,每次我都返回成功了,但是服务器上就是没有照片的。