0
我想將圖像上傳到服務器上的文件夾。該圖像被髮送到一個方法在objective-c到一個PHP腳本。但上傳不會發生!什麼可能是錯的?將圖像上傳到服務器文件夾(objective-c方法爲php腳本)
這裏的OBJ-C方法:
NSURLConnection *getConnection;
NSData *imgData = UIImageJPEGRepresentation(self.imageView.image, 0.7);
NSMutableString *strURL = [NSMutableString stringWithFormat:@"http://.../uploadPhoto.php?ID=2&ph=%@",imgData];
[strURL setString:[strURL stringByAddingPercentEscapesUsingEncoding:NSUTF8StringEncoding]];
NSMutableURLRequest *request = [[NSMutableURLRequest alloc] initWithURL:[NSURL URLWithString:strURL]];
[request setHTTPMethod:@"GET"];
getConnection = [[NSURLConnection alloc] initWithRequest:request delegate:self startImmediately:YES];
這裏的PHP腳本:
$ID = $_GET[ID];
$ph = $_FILES['ph'];
$filename =$ID;
move_uploaded_file($ph['tmp_name'], $_SERVER['DOCUMENT_ROOT']."https://stackoverflow.com/users/$ID/$filename");
請幫幫我!
試POST方法,[要求setHTTPMethod:@ 「POST」],林不知道 – Nightmare