我想上傳視頻文件到指定的網址。當我按下按鈕視頻文件應該上傳到我使用的網址。但沒有反應。任何人都可以給出理由。上傳視頻文件到URL
enter code here
NSString *filePath = [[NSBundle mainBundle]pathForResource:@"3idiots" ofType:@"mov"];
NSURL *uploadurl=[NSURL URLWithString:@"http://115.111.27.206:8081/vblo/upload.jsp"];
//NSData *postVideoData = [NSData dataWithContentsOfFile:filePath];
NSData *postVideoData = [string dataUsingEncoding:NSASCIIStringEncoding allowLossyConversion:YES];
NSString *postVideoLength = [NSString stringWithFormat:@"%d", [postVideoData length]];
NSMutableURLRequest *request12 = [[[NSMutableURLRequest alloc] init] autorelease];
[request12 setURL:uploadurl];
[request12 setHTTPMethod:@"POST"];
[request12 setValue:postVideoLength forHTTPHeaderField:@"Content-Length"];
[request12 setValue:@"application/x-www-form-urlencoded" forHTTPHeaderField:@"Content-Type"];
[request12 setHTTPBody:postVideoData];
NSURLConnection的* theConnection12 = [[NSURLConnection的頁頭] initWithRequest:request12委託:自我];
if(theConnection12) webData12 = [[NSMutableData data] retain];
} 別的 {
}
}
- (無效)連接:(NSURLConnection的*)連接didReceiveResponse:(NSURLResponse *)響應 {
[webData12 setLength:0];
- (void)連接:(NSURLConnection *)連接didReceiveData:(N SDATA *)數據 {
[webData12 appendData:data];
} - (無效)connectionDidFinishLoading:(NSURLConnection的*)連接 { 的NSString * loginStatus12 = [[的NSString的alloc] initWithBytes:[webData12 mutableBytes]長度:[webData12長度]編碼:NSUTF8StringEncoding]; NSLog(loginStatus12);
if(loginStatus12)
{
UIAlertView *statusAlert12 = [[UIAlertView alloc]initWithTitle:nil message:(NSString *)loginStatus12 delegate:self cancelButtonTitle:@"cancel" otherButtonTitles:nil];
[statusAlert12 show];
}
}
你真的需要清理這個代碼後添加此行,這是很難讀......還什麼是在變量「字符串」看起來像你已經註釋掉了實際的視頻數據 – 2010-11-19 13:48:20