Ich versuche, Videodatei auf die angegebene URL zu übertragen. wenn ich die taste drücke, sollte die video-datei in die url hochgeladen werden, die ich benutzt habe. aber es kommt kein atmen. kann irgendeinen Grund dafür geben.Hochladen der Videodatei auf die 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 alloc] initWithRequest: request12 Delegierter: self];
if (theConnection12) { webData12 = [[NSMutableData-Daten] beibehalten];
} sonst {
}
}
- (void) Verbindung: (NSURLConnection *) Verbindung didReceiveResponse: (NSURLResponse *) Antwort {
[webData12 setLength:0];
} - (void) Verbindung: (NSURLConnection *) Verbindung didReceiveData: (N SData *) Daten {
[webData12 appendData:data];
} - (void) connectionDidFinishLoading: (NSURLConnection *) Verbindung { NSString * loginStatus12 = [[NSString alloc] initWithBytes: [webData12 mutableBytes] Länge: [webData12 Länge] Codierung: NSUTF8StringEncoding]; NSLog (loginStatus12);
if(loginStatus12)
{
UIAlertView *statusAlert12 = [[UIAlertView alloc]initWithTitle:nil message:(NSString *)loginStatus12 delegate:self cancelButtonTitle:@"cancel" otherButtonTitles:nil];
[statusAlert12 show];
}
}
Sie wirklich brauchen, um aufzuräumen diesen Code festgelegt, ist es schwer ... auch zu lesen, was in der variable "string" sieht so aus, als ob Sie die eigentlichen Videodaten auskommentiert haben –