好吧,我正在敲打我的头撞在墙上。我有一个POST将图像发送到PHP页面。它一直工作,直到我搬到一个新的但相同的服务器:LINUX运行相同版本的PHP(5.3)。如果我将以下代码中的URL更改为以前的服务器它可以工作,但是一旦我切换到新的,它就不起作用。这是我的代码。有没有人有什么建议?我的帖子看起来不错吗?有没有人看到我能改变的东西?
NSUserDefaults *defaults = [NSUserDefaults standardUserDefaults];
// START NEW METHOD
NSString *urlString = @"http://newserver";
//NSString *urlString = @"http://oldserver";
NSMutableURLRequest *request = [[NSMutableURLRequest alloc] init];
[request setURL:[NSURL URLWithString:urlString]];
[request setHTTPMethod:@"POST"];
NSMutableData *body = [NSMutableData data];
NSString *boundary = @"---------------------------14737809831466499882746641449";
NSString *contentType = [NSString stringWithFormat:@"multipart/form-data; boundary=%@", boundary];
[request addValue:contentType forHTTPHeaderField:@"Content-Type"];
// picture 1
NSData *imageData = UIImageJPEGRepresentation(_image1.image, .10);
[body appendData:[[NSString stringWithFormat:@"\r\n--%@\r\n",boundary] dataUsingEncoding:NSUTF8StringEncoding]];
[body appendData:[[NSString stringWithFormat:@"Content-Disposition: form-data; name=\"image\"; filename=\"image1.png\"\r\n"] dataUsingEncoding:NSUTF8StringEncoding]];
[body appendData:[@"Content-Type: application/octet-stream\r\n\r\n" dataUsingEncoding:NSUTF8StringEncoding]];
[body appendData:[NSData dataWithData:imageData]];
//[body appendData:[[NSString stringWithFormat:@"\r\n--%@--\r\n",boundary] dataUsingEncoding:NSUTF8StringEncoding]];
// close form
[body appendData:[[NSString stringWithFormat:@"--%@--\r\n", boundary] dataUsingEncoding:NSUTF8StringEncoding]];
// set request body
[request setHTTPBody:body];
//return and test
NSData *returnData = [NSURLConnection sendSynchronousRequest:request returningResponse:nil error:nil];
NSString *returnString = [[NSString alloc] initWithData:returnData encoding:NSUTF8StringEncoding];
NSLog(@"Return String: %@", returnString);