Note that there are some explanatory texts on larger screens.

plurals
  1. POAFNetworking Upload Image Strange Response
    text
    copied!<p>I'm trying to upload an image to a server using AFNetworking but i'm recieving a really strange response from server.</p> <p>There is the code:</p> <pre><code>NSUserDefaults *def = [NSUserDefaults standardUserDefaults]; NSData *imageToUpload = UIImageJPEGRepresentation(image, 0.8); AFHTTPClient *client= [AFHTTPClient clientWithBaseURL:[NSURL URLWithString:@"http://www.theserver.net"]]; NSMutableURLRequest *request = [client multipartFormRequestWithMethod:@"POST" path:@"/public_html/imageUpload.php" parameters:nil constructingBodyWithBlock: ^(id &lt;AFMultipartFormData&gt;formData) { [formData appendPartWithFileData: imageToUpload name:@"file" fileName:[NSString stringWithFormat:@"%@.jpg",[def valueForKey:@"cUsuario"]] mimeType:@"image/jpeg"]; }]; AFHTTPRequestOperation *operation = [[AFHTTPRequestOperation alloc] initWithRequest:request]; [operation setCompletionBlockWithSuccess:^(AFHTTPRequestOperation *operation, id responseObject) { NSString *response = [operation responseString]; NSLog(@"response: [%@]",response); [MBProgressHUD hideHUDForView:self.view animated:YES]; } failure:^(AFHTTPRequestOperation *operation, NSError *error) { [MBProgressHUD hideHUDForView:self.view animated:YES]; if([operation.response statusCode] == 403){ NSLog(@"Upload Failed"); return; } NSLog(@"error: %@", [operation error]); }]; [operation start]; </code></pre> <p>And the PHP is:</p> <pre><code>function upload(){ $uploaddir = 'public_html/go2images/'; $file = basename($_FILES['file']['name']); $uploadfile = $uploaddir . $file; if (move_uploaded_file($_FILES['file']['tmp_name'], $uploadfile)) { sendResponse(200, 'Upload Successful'); return true; } sendResponse(403, 'Upload Failed'); return false; } </code></pre> <p>The response that i'm receiving is HTML Tags like html,body... What is going wrong?</p>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload