ios post html代码,iOS post表单提交 报http 500错误详解

完整代码:

NSURL *url = [NSURL URLWithString:[[NSString stringWithFormat:@"%@%@",[utils getAppUploadMeidaUrl],UploadPIC] stringByAddingPercentEscapesUsingEncoding:NSUTF8StringEncoding]];

ASIFormDataRequest  *dictonary = [ASIFormDataRequest requestWithURL:url];

[dictonarysetRequestMethod:@"POST"];

//改用这个方法设置header

NSMutableDictionary *header = [[NSMutableDictionary alloc] init];

[headersetValue:@"multipart/form-data" forKey:@"Content-Type"];

[dictonarysetRequestHeaders:header];

[dictonary  setPostValue:[utils getUnitID]  forKey:@"unitId"];

[dictonary  setPostValue:model.componentsTypeName   forKey:@"objName"];//部件名称

[dictonary  setPostValue:model.componentsCategory   forKey:@"componentsCategory"];//部件大类

[dictonary  setPostValue:model.componentsType  forKey:@"componentsType"];//部件小类

//上传图片

if(self.arrPic.count) {

for(UIImage*eImage in self.arrPic) {

intx =arc4random() %100;

inty =arc4random() %100;

NSData*imageData=UIImageJPEGRepresentation(eImage,100);

NSString*photoName=[NSStringstringWithFormat:@"%zd-%zd.jpg",x,y];

//照片content

[dictonary  addData:imageData   withFileName:photoName  andContentType:@"image/jpeg"  forKey:@"picFile"];

}

}else{

//无照片时,后台规定也必须传 picFile 字段

[dictonary  addData:@"" withFileName:@""  andContentType:@"image/jpeg"  forKey:@"picFile"];

}

[dictonary buildPostBody];

dictonary.shouldAttemptPersistentConnection=NO;

[dictonary setDelegate:self];

[dictonary setDidFailSelector:@selector(responseFailed)];

[dictonary setDidFinishSelector:@selector(responseComplete:)];

[dictonary setTimeOutSeconds:30];

[dictonary startSynchronous];

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值