(sorry for my english) (i open this thread cuase the other thread was for another question)
I have a mobile device application (iOS) and i want to upload an image to my django application In my mobile application i create the POST request (and disable csrf in my django app) using this: - (void)upload{ NSData *imageData = UIImageJPEGRepresentation(imageView.image,90); NSString *urlString = @"http://190.91.43.241:8000/subir/1/"; NSMutableURLRequest *request = [[[NSMutableURLRequest alloc] init]autorelease]; [request setURL:[NSURL URLWithString:urlString]]; [request setHTTPMethod:@"POST"]; NSString *boundary = [NSString stringWithString:@"---------------------------14737809831466499882746641449"]; NSString *contentType=[NSString stringWithFormat:@"multipart/form-data; boundary=%@",boundary]; [request addValue:contentType forHTTPHeaderField:@"Content-Type"]; NSMutableData *body = [NSMutableData data]; [body appendData:[[NSString stringWithFormat:@"\r\n--%@\r\n",boundary] dataUsingEncoding:NSUTF8StringEncoding]]; [body appendData:[[NSString stringWithString:@"Content-Disposition: form-data; name=\"file\"; filename=\"file\"\r\n"] dataUsingEncoding:NSUTF8StringEncoding]]; [body appendData:[[NSString stringWithString:@"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]]; [body appendData:[[NSString stringWithString:@"\r\n"] dataUsingEncoding:NSUTF8StringEncoding]]; // setting the body of the post to the reqeust [request setHTTPBody:body]; // now lets make the connection to the web NSData *returnData = [NSURLConnection sendSynchronousRequest:request returningResponse:nil error:nil]; NSString *returnString = [[NSString alloc] initWithData:returnData encoding:NSUTF8StringEncoding]; NSLog(@"%@",returnString); } And in my Djago app: def upload_image(request): if request.method == 'POST': return request.FILES['file'] return "NO imagen subida" def subir(request,imagen): try: #some functions ...... result = upload_image(request) return HttpResponse(result) except Thrift.TException, tx: print '%s' % (tx.message) but i have a error 500 and if i see the logs i have this: Exception Type: MultiValueDictKeyError Exception Value: "Key 'file' not found in <MultiValueDict: {}>" Any idea? thanks in advance.. (i'm a newbie with django and python) MatÃas Hernandez Arellano Ingeniero de Software/Proyectos en VisionLabs S.A CDA Archlinux-CL www.msdark.archlinux.cl -- You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-users@googlegroups.com. To unsubscribe from this group, send email to django-users+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/django-users?hl=en.