title: HTTP Status Code 500 when uploading video to server in android
body: <p>I'm trying to upload video to server in php and I get Http Status Code 500 error after progress bar complete tasks , I don't know where is the problem in Android file or in JSON file</p>
  
  <p>Android Code for the part of uploading process:</p>
  
  <pre><code>   // Uploading Video  to server
  private class UploadFileToServer extends AsyncTask&lt;Void, Integer, String&gt; {
      @Override
      protected void onPreExecute() {
          // setting progress bar to zero
          progressBar.setProgress(0);
          super.onPreExecute();
      }
  
      @Override
      protected void onProgressUpdate(Integer... progress) {
          // Making progress bar visible
          progressBar.setVisibility(View.VISIBLE);
  
          // updating progress bar value
          progressBar.setProgress(progress[0]);
  
          // updating percentage value
          txtPercentage.setText(String.valueOf(progress[0]) + "%");
      }
  
      @Override
      protected String doInBackground(Void... params) {
          return uploadFile();
      }
  
      @SuppressWarnings("deprecation")
      private String uploadFile() {
          String responseString = null;
  
          HttpClient httpclient = new DefaultHttpClient();
          HttpPost httppost = new HttpPost(Config.FILE_UPLOAD_URL);
  
          try {
  
  
  
              AndroidMultiPartEntity entity = new AndroidMultiPartEntity(
                      new AndroidMultiPartEntity.ProgressListener() {
  
                          @Override
                          public void transferred(long num) {
                              publishProgress((int) ((num / (float) totalSize) * 100));
                          }
                      });
  
              File sourceFile = new File(filePath);
  
              // Adding file data to http body
              entity.addPart("image", new FileBody(sourceFile));
  
              // Extra parameters if you want to pass to server
  
  
              totalSize = entity.getContentLength();
              httppost.setEntity(entity);
  
              // Making server call
              HttpResponse response = httpclient.execute(httppost);
              HttpEntity r_entity = response.getEntity();
  
              int statusCode = response.getStatusLine().getStatusCode();
              if (statusCode == 200) {
                  // Server response
                  responseString = EntityUtils.toString(r_entity);
              } else {
                  responseString = "Error occurred! Http Status Code: "
                          + statusCode;
              }
  
          } catch (ClientProtocolException e) {
              responseString = e.toString();
          } catch (IOException e) {
              responseString = e.toString();
          }
  
          return responseString;
  
      }
  
      @Override
      protected void onPostExecute(String result) {
          Log.e(TAG, "Response from server: " + result);
  
          // showing the server response in an alert dialog
          showAlert(result);
  
          super.onPostExecute(result);
      }
  
  }
  </code></pre>
  
  <p>My JSON file:</p>
  
  <pre><code>&lt;?php
  
  // Path to move uploaded files
  $target_path = "uploads/";
  
  // array for final json respone
  $response = array();
  
   // getting server ip address
   $server_ip = gethostbyname(gethostname());
  
   // final file url that is being uploaded
   $file_upload_url = 'http://' . $server_ip . '/' . 'testApp' . '/' . $target_path;
  
  
   if (isset($_FILES['image']['name'])) {
  $target_path = $target_path . basename($_FILES['image']['name']);
  
  
  
  $response['file_name'] = basename($_FILES['image']['name']);
  
  
  try {
      // Throws exception incase file is not being moved
      if (!move_uploaded_file($_FILES['image']['tmp_name'], $target_path)) {
          // make error flag true
          $response['error'] = true;
          $response['message'] = 'Could not move the file!';
      }
  
      // File successfully uploaded
      $response['message'] = 'File uploaded successfully!';
      $response['error'] = false;
      $response['file_path'] = $file_upload_url . basename($_FILES['image']['name']);
  } catch (Exception $e) {
      // Exception occurred. Make error flag true
      $response['error'] = true;
      $response['message'] = $e-&gt;getMessage();
  }
   } else {
  // File parameter is missing
  $response['error'] = true;
  $response['message'] = 'Not received any file!F';
   }
  
   // Echo final json response to client
  echo json_encode($response);
  ?&gt;
  </code></pre>