EDN Admin
Well-known member
hi all
im developing a windows 8 metro app that uses a WCF service to connect to a sql server database.
code below gets a image from the users pc
<pre class="prettyprint async void btnUploadProfPic_Click(object sender, RoutedEventArgs e)
{
//upload user p pic
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)
{
using (IRandomAccessStream fileStream = await file.OpenAsync(Windows.Storage.FileAccessMode.Read))
{
BitmapImage image = new BitmapImage();
image.SetSource(fileStream);
userPic.Source = image;
var filestream2 = fileStream.AsStreamForRead();
byte[] imageByte = new byte[filestream2.Length];
filestream2.Read(imageByte, 0, imageByte.Length - 1);
user.ProfilePic = imageByte; // add to database
}
}
}[/code]
now this works with smaller files but when i try to upload a file larger then 1mb then it gives the following error
The remote server returned an unexpected response: (413) Request Entity Too Large.
pls help
View the full article
im developing a windows 8 metro app that uses a WCF service to connect to a sql server database.
code below gets a image from the users pc
<pre class="prettyprint async void btnUploadProfPic_Click(object sender, RoutedEventArgs e)
{
//upload user p pic
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)
{
using (IRandomAccessStream fileStream = await file.OpenAsync(Windows.Storage.FileAccessMode.Read))
{
BitmapImage image = new BitmapImage();
image.SetSource(fileStream);
userPic.Source = image;
var filestream2 = fileStream.AsStreamForRead();
byte[] imageByte = new byte[filestream2.Length];
filestream2.Read(imageByte, 0, imageByte.Length - 1);
user.ProfilePic = imageByte; // add to database
}
}
}[/code]
now this works with smaller files but when i try to upload a file larger then 1mb then it gives the following error
The remote server returned an unexpected response: (413) Request Entity Too Large.
pls help
View the full article