Telerik RadUpload how to get bytes
Posted on: Tue Dec 01 13:33:44 -0800 2009. Updated on: Tue Dec 01 13:37:16 -0800 2009.
Category: DotNet
Category: DotNet
For use with the Telerik RadUpload COntrol. This shows how to quickly process an uploaded file in codebehind so you get it into a byte array ready to be put in the database.
protected void ButtonUpload_Click(object sender, EventArgs e)
{
if (RadUpload1.UploadedFiles.Count > 0)
{
string filename = RadUpload1.UploadedFiles[0].FileName;
int length = (int)RadUpload1.UploadedFiles[0].InputStream.Length;
byte[] bytes = new byte[length];
RadUpload1.UploadedFiles[0].InputStream.Read(bytes, 0, length);
// Now simply call your Data Model function to create item, bytes contains data
CreateFile(filename, bytes, RadUpload1.UploadedFiles[0].ContentType);
}
}