Quantcast
Channel: ASP.NET AJAX + Ajax Control Toolkit (ACT)
Viewing all articles
Browse latest Browse all 5678

AjaxFileUpload: Need File as byte[]

$
0
0

Hello,

i just started to use the cool AjaxFileUpload Control of the new release of the AJAX Control Toolkit. I wanted to replace the standard FileUploadControl.

I save all Images in my Database and therefore i need the raw content. I accessed this in the standard control by using FileUpload.FileBytes.

Problem: AjaxFileUpload does not own such a property. It even has only one Save(String filepath)-Method and nothing to save it into a stream  - or do i miss something?

Thanks in advance for your help!

EDIT: I always did it like this:

if (!ImageFileUpload.HasFile)
            return;

        byte[] imageBytes = ImageFileUpload.FileBytes;
        MemoryStream memoryStream = new MemoryStream(imageBytes, false);
        imageBytes = Core.GenerateScaledImage(640, memoryStream);

        if (imageBytes.Length > 65535)
        {
            //Image too big after scaling
            UploadFeedbackControl.ReportException("Selected Image is too big");
        }
        else
        {
            string[] splittedName = ImageFileUpload.FileName.Split('.');
            string extension = splittedName[splittedName.Length - 1];
            string filename = string.Empty;
            for (int i = 0; i <= splittedName.Length - 2; i++)
                filename += splittedName[i];

            m_Upload.PK_Image = Guid.NewGuid();
            m_Upload.ImageFileName = filename;
            m_Upload.ImageExtension = extension;
            m_Upload.ImageData = imageBytes;

            Session["m_Upload"] = m_Upload;

            ImageImage.ImageUrl = "GetData.aspx?Type=ImagePreview";
        }


Viewing all articles
Browse latest Browse all 5678

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>