title: Post web service to upload pdf file
body: <p>I have made a script in php to upload pdf file on server from iOS application but I don't understand why it says undefined index pdfFile please let me know if you catch my mistake </p>
  
  <p>Here is my iOS code </p>
  
  <pre><code> Alamofire.upload(
          multipartFormData: { multipartFormData in
  
            //  multipartFormData.append(pdfUrl!, withName: "pdfFile")
  
              let pdfData = NSData(contentsOf: pdfUrl!)
              print((pdfData as? Data)!)
              multipartFormData.append((pdfData as? Data)!, withName: "pdfFile", mimeType: "application/pdf")
  
  
          },
          to: "http://www.webservice.pixsterstudio.com/uploadpdf.php",
          encodingCompletion: { encodingResult in
              switch encodingResult {
              case .success(let upload, , ):
                  upload.responseJSON { response in
                      debugPrint(response)
                      print(response.result)
                  }
              case .failure(let encodingError):
                  print(encodingError)
              }
          }
      )
  </code></pre>
  
  <p>Here is my PHP  web service script:- uploadpdf.php</p>
  
  <pre><code>  &lt;?php
  
  if ($_FILES['pdfFile']['type'] == "application/pdf") {
      $source_file = $_FILES['pdfFile']['tmp_name'];
      $dest_file = "webservice.pixsterstudio.com/upload/".$_FILES['pdfFile']['name'];
  
      if (file_exists($dest_file)) {
          print "The file name already exists!!";
      }
      else {
          move_uploaded_file( $source_file, $dest_file )
          or die ("Error!!");
          if($_FILES['pdfFile']['error'] == 0) {
              $Return['status'] = 'true';
              $Return['message'] = "Pdf file uploaded successfully!";
              //print "Pdf file uploaded successfully!";
              //print "&lt;b&gt;&lt;u&gt;Details : &lt;/u&gt;&lt;/b&gt;&lt;br/&gt;";
              //print "File Name : ".$_FILES['pdfFile']['name']."&lt;br.&gt;"."&lt;br/&gt;";
          //  print "File Size : ".$_FILES['pdfFile']['size']." bytes"."&lt;br/&gt;";
          //  print "File location : upload/".$_FILES['pdfFile']['name']."&lt;br/&gt;";
  
  
  
          }
      }
  }
  else {
      if ( $_FILES['pdfFile']['type'] != "application/pdf") {
              $Return['status'] = 'false';
              $Return['message'] = "Pdf file not uploaded !";
          //print "Error occured while uploading file : ".$_FILES['pdfFile']['name']."&lt;br/&gt;";
          //print "Invalid  file extension, should be pdf !!"."&lt;br/&gt;";
          //print "Error Code : ".$_FILES['pdfFile']['error']."&lt;br/&gt;";
      }
  }
    header('Content-type: application/json');
    echo  json_encode($Return);
  
   ?&gt;
  </code></pre>