I have an application for Windows 8 that works very well, and now I want to write the same application for Windows Phone 8, but I get only a black image and not the correct image.
This is my image file upload code.
if ((_fileType == ".jpg" || _fileType == ".png" || _fileType == ".jpeg") && _fileSize < 3500000) { byte[] myPicArray = ConvertToBytes(_bmpFile); HttpClient httpClient = new HttpClient(); httpClient.BaseAddress = new Uri(MYURI); MultipartFormDataContent form = new MultipartFormDataContent(); HttpContent content = new ByteArrayContent(myPicArray); form.Add(content, "media", _randomStringFileName + _fileType); HttpResponseMessage response = await httpClient.PostAsync("upload.php", form); }
and this is the code to convert my image to an array of bytes
private byte[] ConvertToBytes(BitmapImage bitmapImage) { using (MemoryStream ms = new MemoryStream()) { WriteableBitmap btmMap = new WriteableBitmap (bitmapImage.PixelWidth, bitmapImage.PixelHeight);
Does anyone have an idea why I only get a black image and not an image? Image was selected by PhotoChooseTask.
source share