#import <Foundation/Foundation.h>
@interface PicUpload : NSObject
+ (NSString *)postRequestWithURL: (NSString *)url // IN
postParems: (NSMutableDictionary *)postParems // IN
picFilePath: (NSMutableArray *)picFilePath // IN
picFileName: (NSMutableArray *)picFileName ;
@end
.m文件实现
// Copyright (c) 2014年 Clover. All rights reserved.
#import "PicUpload.h"
#import "SVProgressHUD.h"
#import "SBJson.h"
#import "Singleton.h"
@implementation PicUpload
static NSString * const FORM_FLE_INPUT = @"file1";
+ (NSString *)postRequestWithURL: (NSString *)url
postParems: (NSMutableDictionary *)postParems
picFilePath: (NSMutableArray *)picFilePath
picFileName: (NSMutableArray *)picFileName
{
NSString *hyphens = @"--";
NSString *boundary = @"*****";
NSString *end = @"\r\n";
NSMutableData *myRequestData1=[NSMutableData data];
//遍历数组,添加多张图片
for (int i = 0; i < picFilePath.count; i ++) {
NSData* data;
UIImage *image=[UIImage imageWithContentsOfFile:[picFilePath objectAtIndex:i]];
//判断图片是不是png格式的文件
if (UIImagePNGRepresentation(image)) {
//返回为png图像。
data = UIImagePNGRepresentation(image);
}else {
//返回为JPEG图像。
data = UIImageJPEGRepres