我尝试使用ASIHTTPRequest上传到服务器。但我似乎没有得到它。下面是实现的代码。有什么建议吗?
NSArray *paths = NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES);
NSString *documentsDirectory = [paths objectAtIndex:0];
//make a file name to write the data to using the documents directory:
NSString *fileName = [NSString stringWithFormat:@"%@/LightMode.txt",
documentsDirectory];
//create content - four lines of text
NSString *content = @"studyMode";
//save content to the documents directory
[content writeToFile:fileName
atomically:NO
encoding:NSStringEncodingConversionAllowLossy
error:nil];
NSURL *url = [NSURL URLWithString:@"http://spider90.dyndns.org:8080/sid/"];
ASIFormDataRequest *request = [ASIFormDataRequest requestWithURL:url];
NSData *postData = [NSData dataWithContentsOfURL:@"%@/LightMode.txt"];
[request addData:postData withFileName:@"LightMode.txt" andContentType:@"txt" forKey:@"text"];
[request setDelegate:self];
[request startSynchronous];