Uploading BinaryImage with LINQ

2 posts, 1 answers
  1. Francisco
    Francisco avatar
    15 posts
    Member since:
    Sep 2010

    Posted 29 Sep 2010 Link to this post


    I want to use a BinaryImage to store an image I have in the database. Since I'm using LINQ, it is very easy to retrieve the data and assign it to the BinaryImage.DataValue property.

    The problem is doing the option to ‘upload’ an image. I want to use a RadUpload, preview the image and, instead of saving the file to my server, passing the binary information to the property of my Entity made by LINQ.

    I’ve tried using a handler but I don’t know how to connect the binary data to my LINQ Entity.

    Kind Regards,

  2. Answer
    Veli avatar
    2002 posts

    Posted 29 Sep 2010 Link to this post

    Hi Francisco,

    If you are using RadUpload for uploading your image, the control's UploadedFiles collection gives you the uploaded image data. Each item in the collection is a Telerik.Web.UI.UploadedFile instance. You can use the latter's InputStream property to get a stream containing your uploaded data. You can then extract the bytes from the stream and pass them to your LINQ entity. Please refer to the following demo and help article for this scenario:

    Demo: Manipulating uploaded files

    Help: Manipulating uploaded files

    If you are using RadAsyncUpload, you can use the above approach, but you also have another option. You can implement a custom asynchronous upload handler that can save your images directly to the database using LINQ. For an example on that:

    Demo: Images uploader

    Help: How to extend async upload handler

    I hope this helps.

    the Telerik team
    Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items
Back to Top