Silverlight / WPF - upload image to database , silverlight

Asked By Saurabh ......
10-Jun-09 07:02 AM
hi,

in silverlight how can i upload image or file to database.
i m using wcf service + LINQ  for database connectivity. so how can i send the image to wcf service to upload.


  Santhosh N replied to Saurabh ......
10-Jun-09 07:22 AM

check this one explaining how to accomplish this..

http://silverlight.net/forums/t/64867.aspx

  samjayander thiagarajan replied to Saurabh ......
18-Mar-10 02:34 AM
Hi,

1. WCF + LINQ:
          are you going to store the image/file to database of to a physcial location to the server?
for either methods, you can expose a method in WCF which would accept a byte array as argument. so that you can accept the file/image as byte array. [This has its own size limitations. You have to adjust your binding configurations so that a acceptable size gets transferred. If you are in need of extremely large files/images, you have use some workarounds.]

UploadFile(byte[] content)
{
  // write the file to disk
  using (FileStream FileStream = new FileStream(tempFileName, FileMode.Create))
  {
    FileStream.Write(content, 0, content.Length);
    FileStream.Close();
    FileStream.Dispose();
  }
}


2. Silverlight:
Here is the code to upload file using byte array.

OpenFileDialog dlg = new OpenFileDialog();
dlg.Filter = "Excel Files (*.xls)|*.xls";
dlg.Multiselect = false;
if (dlg.ShowDialog() ?? false)
{
  //open the file as a stream
  using (Stream stream = dlg.File.OpenRead())
  {
    //put the stream in the BinaryReader
    BinaryReader binary = new BinaryReader(stream);
    //Read bytes from the BinaryReader and put them into a byte array.
    Byte[] File = binary.ReadBytes((int)stream.Length);
  
     AdminServiceClient adminClient = <get the proxy>;
    adminClient.UploadFileCompleted += <hook to completed event>
    adminClient.UploadFile(File);
  }
}

HTH,
Sam.

Create New Account
help
is the code to upload file using byte array. OpenFileDialog dlg = new OpenFileDialog(); dlg.Filter = "Excel Files (*.xls) | *.xls"; dlg.Multiselect = false; if (dlg.ShowDialog() ?? false) { / / open the file as a Refer this link http: / / www.eggheadcafe.com / community / aspnet / 56 / 10102213 / upload-image-to-database- --silverlight.aspx http: / / forums.silverlight.net / t / 64867.aspx Regards 1. WCF + LINQ: are you going to store the image as byte array. [This has its own size limitations. You have to adjust your binding configurations so that a acceptable size gets transferred. If you are in need of extremely large FileStream(tempFileName, FileMode.Create)) { FileStream.Write(content, 0, content.Length); FileStream.Close(); FileStream.Dispose(); } } 2. Silverlight: Here is the code to upload file using byte array. OpenFileDialog dlg = new OpenFileDialog(); dlg.Filter = "Excel Files (*.xls) | *.xls" ; dlg.Multiselect = false ; if (dlg.ShowDialog() ?? false ) { / / open the file as a
the actions to technologies like Windows Application, Web Application, and WPF Application and also to Silverlight, with the help of feature pack. In case we want to extend support to any feature of CUIT involves intent aware recording. Eg: In case we want to start MS Excel, clicked on the Start button, entered Excel in Search and then selected Microsoft Excel 2010, then the recording will only be done while Excel is launched. Let us see some steps: Step 1 . With Visual Studio 2010 launched, create correct controls are displayed with the correct values. For more information about which platforms and configurations are supported by coded UI tests, see Supported Configurations and Platforms for Coded UI Tests and Action Recordings . Creating a coded UI test generates
formats supporting 90, 180 and 360 degrees rotation; does not require any special or complex configurations; and images are maintained when exporting your reports from Reporting Services to other file formats such as Adobe PDF, Excel - xls files, Word - doc files, TIFF, and Web archive. Barcode Professional does support most popular is on imaging-related .NET components and class libraries for ASP.NET, Windows Forms, WPF, Silverlight and Mobile applications as well as SQL Server Reporting Services solutions. Founded in 2003 by
excel Excel excel Excel Discussions Excel (1) ExcelSalesAid (1) GuillettMicrosoft (1) SalesAid (1) Dguillett1 (1) I will certainly try to - - Don Guillett Microsoft MVP Excel SalesAid Software dguillett1@austin.rr.com keywords: excel description: excel