This is a migrated thread and some comments may be shown as answers.

Uploading BinaryImage with LINQ

1 Answer 63 Views
BinaryImage
This is a migrated thread and some comments may be shown as answers.
Francisco
Top achievements
Rank 1
Francisco asked on 29 Sep 2010, 09:25 AM

Hi,

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,

1 Answer, 1 is accepted

Sort by
0
Accepted
Veli
Telerik team
answered on 29 Sep 2010, 04:11 PM
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.

Veli
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
Tags
BinaryImage
Asked by
Francisco
Top achievements
Rank 1
Answers by
Veli
Telerik team
Share this question
or