title: Upload doc, pdf,xls etc, from android application to php server
body: <p>I get stuck at that place and unable to send doc file to php server. 
  I am using this code. </p>
  
  <p>Here is PHP code.    </p>
  
  <p>
  
  <pre><code>if($_SERVER['REQUEST_METHOD']=='POST'){
  
      $image = $_POST['image'];
              $name = $_POST['name'];
  
      require_once('dbConnect.php');
  
      $sql ="SELECT id FROM volleyupload ORDER BY id ASC";
  
      $res = mysqli_query($con,$sql);
  
      $id = 0;
  
      while($row = mysqli_fetch_array($res)){
              $id = $row['id'];
      }
  
      $path = "uploads/$id.doc";
  
      $actualpath = "http://10.0.2.2/VolleyUpload/$path";
  
      $sql = "INSERT INTO volleyupload (photo,name) VALUES ('$actualpath','$name')";
  
      if(mysqli_query($con,$sql)){
          file_put_contents($path,base64_decode($image));
          echo "Successfully Uploaded";
      }
  
      mysqli_close($con);
  }else{
      echo "Error";
  }
  </code></pre>
  
  <p>Here is Java code </p>
  
  <pre><code>private void showFileChooser() {
      Intent intent = new Intent();
      intent.setType("file/*");
      intent.setAction(Intent.ACTION_GET_CONTENT);
      startActivityForResult(Intent.createChooser(intent, "Select Picture"),
              PICK_IMAGE_REQUEST);
  }
  </code></pre>
  
  <p>I called asynTask on upload button.</p>
  
  <pre><code>if (v == buttonUpload) {
          // uploadImage();
          new PostDataAsyncTask().execute();
      }
  </code></pre>
  
  <p>A function calls in doInBackground is</p>
  
  <pre><code>private void postFile() {
      try {
  
          // the file to be posted
           String textFile = Environment.getExternalStorageDirectory()
           + "/Woodenstreet Doc.doc";
           Log.v(TAG, "textFile: " + textFile);
  
          // the URL where the file will be posted
          String postReceiverUrl = "http://10.0.2.2/VolleyUpload/upload.php";
          Log.v(TAG, "postURL: " + postReceiverUrl);
  
          // new HttpClient
          HttpClient httpClient = new DefaultHttpClient();
  
          // post header
          HttpPost httpPost = new HttpPost(postReceiverUrl);
  
          File file = new File(filePath.toString());
          FileBody fileBody = new FileBody(file);
  
          MultipartEntity reqEntity = new MultipartEntity(
                  HttpMultipartMode.BROWSER_COMPATIBLE);
          reqEntity.addPart("file", fileBody);
          httpPost.setEntity(reqEntity);
  
          // execute HTTP post request
          HttpResponse response = httpClient.execute(httpPost);
          HttpEntity resEntity = response.getEntity();
  
          if (resEntity != null) {
  
              String responseStr = EntityUtils.toString(resEntity).trim();
              Log.v(TAG, "Response: " + responseStr);
  
              // you can add an if statement here and do other actions based
              // on the response
          }
  
      } catch (NullPointerException e) {
          e.printStackTrace();
      } catch (Exception e) {
          e.printStackTrace();
      }
  }
  </code></pre>
  
  <p>The exception I get is that</p>
  
  <pre><code>java.io.FileNotFoundException: content:/com.topnet999.android.filemanager/storage/0F02-250A/test.doc: open failed: ENOENT (No such file or directory)
  </code></pre>
  
  <p>There is file in emulator - test.doc.
  Is there is any thing I miss in code, please help me.
  Or suggest a tutorial to upload pdf to php server.</p>
  
  <p>Thanks In Advance.</p>