Note that there are some explanatory texts on larger screens.

plurals
  1. POUpload image with POST (Windows 8)
    text
    copied!<p>I have the code that have to upload image to the uri with parametr file1. But the code doesn't work. Why an image doesn't uploading?</p> <p>Here is my code:</p> <pre><code>public void Upload { string oauthUrl = "http://MY_Uri"; HttpClient theAuthClient = new HttpClient(); HttpRequestMessage request = new HttpRequestMessage(HttpMethod.Post, oauthUrl); StorageFolder storageFolder = KnownFolders.PicturesLibrary; StorageFile sf = await storageFolder.GetFileAsync("ss.png"); IBuffer buffer = await FileIO.ReadBufferAsync(sf); byte[] fileData = buffer.ToArray(); Encoding encoding = Encoding.GetEncoding("Windows-1252"); string text = encoding.GetString(fileData, 0, fileData.Length); string content = @"file1=" + text + ""; txt.Text = content; StorageFolder storageFolder2 = KnownFolders.PicturesLibrary; StorageFile sampleFile = await storageFolder2.CreateFileAsync("sample.txt"); await Windows.Storage.FileIO.WriteTextAsync(sampleFile, "" + text + ""); request.Method = HttpMethod.Post; request.Content = new StreamContent(new System.IO.MemoryStream(System.Text.Encoding.UTF8.GetBytes(content))); request.Content.Headers.Add("Content-Type", "application/x-www-form-urlencoded"); try { HttpResponseMessage response = await theAuthClient.SendAsync(request); handleResponse(response); } catch (HttpRequestException hre) { } } public async void handleResponse(HttpResponseMessage response) { string content = await response.Content.ReadAsStringAsync(); Account account = JsonConvert.DeserializeObject&lt;Account&gt;(content); if (content != null) { } } </code></pre> <p>Thanks for the help!!!!!!!!</p> <p>"It looks like your post is mostly code; please add some more details."</p>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload