title: how to GET or POST multipart data request in PHP
body: <p>I am sending multipart request from iOS to upload image or doc file on server.
  My request is like </p>
  
  <pre><code>    UIImage *im = [UIImage imageNamed:@"57X57.png"];
      NSData *imageData = UIImageJPEGRepresentation(im, 90);
      NSString *urlString = @"my URL/upload.php";
  
  
      NSMutableURLRequest *request = [[NSMutableURLRequest alloc] init];
      [request setURL:[NSURL URLWithString:urlString]];
  
      [request setHTTPMethod:@"POST"];
      NSString *boundary = @"---------------------------14737809831466499882746641449";
      NSString *contentType = [NSString stringWithFormat:@"multipart/form-data; boundary=%@",boundary];
      [request addValue:contentType forHTTPHeaderField: @"Content-Type"];
      NSString *imgName = @"raj.png";
      NSLog(@"image name : %@",imgName);
  
      NSMutableData *body = [NSMutableData data];
      [body appendData:[[NSString stringWithFormat:@"\r\n--%@\r\n",boundary] dataUsingEncoding:NSUTF8StringEncoding]];
  
      [body appendData:[[NSString stringWithString:[NSString stringWithFormat:@"Content-Disposition: form-data; name=\"files\"; filename=\"%@\"\r\n", imgName]] 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]];
  
      [request setHTTPBody:body];
      NSLog(@"setRequest : %@", request);
  
  
      NSData *returnData = [NSURLConnection sendSynchronousRequest:request returningResponse:nil error:nil];
      NSString *returnString = [[NSString alloc] initWithData:returnData encoding:NSUTF8StringEncoding];
  
      NSLog(@"returnstring is : %@",returnString);
  </code></pre>
  
  <p>and at PHP end </p>
  
  <pre><code>&lt;?php
      print_r($_FILES);
      print_r($_POST);
  ?&gt;
  </code></pre>
  
  <p>When I write <strong>print_r($_FILES)</strong> it will give me output at iOS end as </p>
  
  <pre><code>returnstring is : Array
  (
      [files] =&gt; Array
          (
              [name] =&gt; raj.png
              [type] =&gt; application/octet-stream
              [tmp_name] =&gt; /tmp/phpI93DO3
              [error] =&gt; 0
              [size] =&gt; 366784
          )
  )
  {"success":1}
  </code></pre>
  
  <p>But at PHP server side the array is empty i.e Array().</p>
  
  <p>I am new to web service development in PHP. Please suggest me where I am wrong. 
  I am very confident about iOS side code (i.e sending multipart request to server) because I used the same code to upload multipart data to java based web service (RESTFull web service in java)  But I not having much knowledge about PHP side. 
  Please guide me how would I fetch multipart request at PHP end.</p>