我想以这种格式在 maultipartform 中提出请求——
<form action="http://xyz.com/web/video/formupload/01f7e4d2-9484-44ed-9e5d-bb4b7ff67739" method="post"
enctype="multipart/form-data" ">
<input id="uploadedFile" type="file" name="uploadedFile"/>
<input type="hidden" name="token" value="TOKEN"/>
<input type="submit" value="go" />
</form>
我为此目的使用 asiformdatarequest 类..这是我下面的代码
ASIFormDataRequest *videoUploadRequest = [ASIFormDataRequest requestWithURL:[NSURL URLWithString:[tokenValue objectForKey:@"url"]]];
[videoUploadRequest setPostFormat:ASIMultipartFormDataPostFormat];
[videoUploadRequest addData:[tokenValue objectForKey:@"token"] forKey:@"token"];
[videoUploadRequest addData:video withFileName:@"New Video" andContentType:(@"video/*") forKey:@"uploadedFile"];
[videoUploadRequest startSynchronous];
NSError *error = [videoUploadRequest error];
if (!error)
{
NSString *response = [videoUploadRequest responseString];
NSLog(@"upload response: %@", response);
}
else
{
NSLog(@"Eror -- %@", error);
}
我收到一条错误消息
Eror -- Error Domain=ASIHTTPRequestErrorDomain Code=3 "Authentication needed" UserInfo=0x1e5ee090 {NSLocalizedDescription=Authentication needed}
请任何人告诉我代码是否有问题..请求的格式或其他任何内容..
提前致谢 !