title: Upload a image on server iPhone
body: <p>I am new to iPhone. I want to upload an image to a server. I have url</p>
  
  <p><strong>http://lifestander.com:8080/fileupload/uploadfile.html?username=tom&amp;password=1234&amp;directory=ebay&amp;filename=fantacy.jpg</strong>  </p>
  
  <p>I use the following method for uploading the file, but the result in console is: <strong>{"success":"false", "message":"Authentication Failed"}</strong></p>
  
  <p>I do not understand the output in the console. So please tell me what do I do wrong, or improve my code. What to do?</p>
  
  <p>Thanks.</p>
  
  <pre><code>-(void)uploadFile{
  
  UIImage* theImage = [UIImage imageNamed:@"images.jpg"];
  NSString* path = [[NSBundle mainBundle] pathForResource:@"images" ofType:@"jpg"];
  
  
  
  NSString *photoUploadURLString=@"http://lifestander.com:8080/fileupload/uploadfile.html";
  
  NSURL *url = [NSURL URLWithString: photoUploadURLString];
  
  ASIFormDataRequest *request = [ASIFormDataRequest requestWithURL:url];
  
  [request setUseKeychainPersistence:YES];
  
  
  
  // Upload an image
  NSData *imageData = UIImageJPEGRepresentation(theImage,1.0);
  
  [request addPostValue:@"tom" forKey:@"username"];
  [request addPostValue:@"1234" forKey:@"password"];
  [request addPostValue:@"ebay" forKey:@"directory"];
  
  
  
  [request setData:imageData withFileName:@"images.jpg" andContentType:@"image/jpg" forKey:@"filename"];
  
  [request setDelegate:self];
  [request setDidFinishSelector:@selector(uploadRequestFinished:)];
  [request setDidFailSelector:@selector(uploadRequestFailed:)];
  
  [request startAsynchronous];
  
  
  
  }
  </code></pre>