title: upload an image into mysql database using windows universal app
body: <p>i've been trying to insert an image from my phone into mysql database using a windows universal app and 2 php files . 
  here is my xaml code ` 
          
          
          
          </p>
  
  <pre><code>    &lt;TextBox x:Name="UserName" HorizontalAlignment="Left" Margin="143,23,0,0" TextWrapping="Wrap" Text="nameB" VerticalAlignment="Top" Height="2" Width="174"/&gt;
      &lt;TextBox x:Name="UserMail" HorizontalAlignment="Left" Margin="151,85,0,0" TextWrapping="Wrap" Text="emailB" VerticalAlignment="Top" Height="2" Width="174"/&gt;
      &lt;TextBox x:Name="UserImage" HorizontalAlignment="Left" Margin="153,218,0,0" TextWrapping="Wrap" Text="imageB" VerticalAlignment="Top" Height="2" Width="119"/&gt;
      &lt;PasswordBox  x:Name="UserPassword" HorizontalAlignment="Left" Margin="185,145,0,0"   VerticalAlignment="Top" Height="2" Width="141"/&gt;
  
      &lt;Button x:Name="UploadImage" Content="upload" HorizontalAlignment="Left" Margin="284,218,0,0" VerticalAlignment="Top" Click="upload_Click"/&gt;
      &lt;Button x:Name="SubmitUser" Content="submit" HorizontalAlignment="Left" Margin="242,297,0,0" VerticalAlignment="Top" Click="submit_Click"/&gt;
  &lt;/Grid&gt;`
  </code></pre>
  
  <p>and here is my mainpage.xaml.cs</p>
  
  <pre><code>public sealed partial class MainPage : Page
  {
  
  
      HttpClient client = new HttpClient();
  
      public MainPage()
      {
          this.InitializeComponent();
      }
  
      private async void upload_Click(object sender, RoutedEventArgs e)
      {
  
          FileOpenPicker openPicker = new FileOpenPicker();
          openPicker.ViewMode = PickerViewMode.Thumbnail;
          openPicker.SuggestedStartLocation = PickerLocationId.PicturesLibrary;
          openPicker.FileTypeFilter.Add(".jpg");
          openPicker.FileTypeFilter.Add(".jpeg");
          openPicker.FileTypeFilter.Add(".png");
  
          StorageFile file = await openPicker.PickSingleFileAsync();
          if (file != null)
          {
              // Application now has read/write access to the picked file
              UserImage.Text =  file.Name;
          }
  
      }
  
      private async void submit_Click(object sender, RoutedEventArgs e)
      {
          /* NameValueCollection UserInfo = new NameValueCollection();
           UserInfo.Add("UserName", UserName.Text);
           UserInfo.Add("UserMail", UserMail.Text);
  
           UserInfo.Add("UserPassword", UserPassword.Password);
           UserInfo.Add("UserImage", UserImage.Text);
           */
          ///*********/////
  
  
  
  
          String url = "http://172.19.241.135/tutorial/insertStudent.php";
          var values = new List&lt;KeyValuePair&lt;String, String&gt;&gt;
          {
              new KeyValuePair&lt;string, string&gt;("UserName",UserName.Text),
              new KeyValuePair&lt;string, string&gt;("UserMail",UserMail.Text),
              new KeyValuePair&lt;string, string&gt;("UserPassword",UserPassword.Password),
              new KeyValuePair&lt;string, string&gt;("UserImage",UserImage.Text)
  
          };
  
  
          HttpResponseMessage response = new HttpResponseMessage();
          try
          {
              response = await client.PostAsync(url, new FormUrlEncodedContent(values));
  
              if (response.IsSuccessStatusCode)
              {
                  Debug.WriteLine(response.StatusCode.ToString());
                  var dialog = new MessageDialog("added succesfully ");
                  await dialog.ShowAsync();
              }
              else
              {
                  // problems handling here
                  string msg = response.IsSuccessStatusCode.ToString();
  
                  throw new Exception(msg);
              }
          }
          catch (Exception exc)
          {
              // .. and understanding the error here
              Debug.WriteLine(exc.ToString());
          }
  
  
  
      }
  }
  </code></pre>
  
  <p>and i'm stuck now as i was trying to use a windows phone code , but i can't find a replacement for </p>
  
  <p><code>byte[] insertuser= client.uploadValues("",values);
  client.Headers.Add("content_type","binary/octet_stream");
  byte[] insertUserImage=client.uploadFile("",FileChooser.FileName) ;</code></p>
  
  <p>it seems that these methods are no more available in windows universal apps
  any help would be appreciated</p>