title: Send an image file using sockets , Android to Python
body: <p>Im trying to send an image from an android client to a python server , I have achieved it before with a python test client and the server. Basically my client app takes a form consisting of users details and an image. Once the user selects the image I get the uri in the onActivityResult method and parse it to a string Like so </p>
  
  <p><code>selectedImagePath = selectedImageUri.toString();</code></p>
  
  <p>when the user hits submit button on the form the sending activity is invoked with the form data as extras in an array in a bundle like so.</p>
  
  <p><code>Bundle b=new Bundle();
   b.putStringArray("regValues", new String[]{name,email,selectedImagePath});</code></p>
  
  <p>in  the sending activity I establish a connection with the server and attempt to send the image like so .</p>
  
  <p>` 
  //establish link with the server</p>
  
  <pre><code>    try{
  
       //refer to the host computer's loopback interface
       host = InetAddress.getByName("10.0.2.2"); 
       link = new Socket(host,port);
       in = new BufferedReader(new InputStreamReader(link.getInputStream()));
  
       //access the strings that were passed to this activity 
       Bundle b = this.getIntent().getExtras();
       String[] regFormValues = b.getStringArray("regValues");
  
       //display connection confirmation
  
       String message = in.readLine();
       status.setText(message);
  
  
  
          File myFile = new File (regFormValues[2]);
          byte [] mybytearray  = new byte [(int)myFile.length()];
          FileInputStream fis = new FileInputStream(myFile);
          BufferedInputStream bis = new BufferedInputStream(fis);
          bis.read(mybytearray,0,mybytearray.length);
          OutputStream os = link.getOutputStream();
  
          os.write(mybytearray,0,mybytearray.length);
          os.flush();
          link.close();
  
  
  
  
  
      }
      catch(IOException e ){
  
       e.printStackTrace();
  
      }
      `
  </code></pre>
  
  <p>It connects to the server no problem , the
   server creates a file for output to write the data to as usual but it just appears empty so no data is being recieved. I think it may be a problem with the file path on the client side. Any Ideas ? </p>
  
  <p>EDIT: Basically I would like to know if I am accessing the image file in the right way or if you have any better suggestions for accessing and sending it.</p>