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

How to rewrite the asp:upload to rad:upload.

1 Answer 82 Views
Upload (Obsolete)
This is a migrated thread and some comments may be shown as answers.
mathieu cupryk
Top achievements
Rank 1
mathieu cupryk asked on 04 Nov 2009, 02:09 PM
How can I rewrite the below?

 //protected void UploadButton_Click(object sender, EventArgs e)
        //{

        //    //get the image file that was posted (binary format)
        //    if (FileUpload1.PostedFile == null || FileUpload1.PostedFile.FileName == "")
        //    {
        //        lblResult.Text = "Please Select the file";
        //    }
        //    else
        //    {
        //        try
        //        {
        //            if (FileUpload1.HasFile)
        //            {
        //                Int32 length = FileUpload1.PostedFile.ContentLength;

        //                Byte[] theImage = new Byte[length];
        //                Bitmap image = ResizeImage(FileUpload1.PostedFile.InputStream, 300, 300);
        //                // Initialize the stream to read the uploaded file.
        //                System.IO.Stream myStream = FileUpload1.FileContent;

        //                theImage = BmpToBytes_MemStream(image);


        //                // Read the file into the byte array.
        //                myStream.Read(theImage, 0, length);


        //                string fileName = FileUpload1.FileName.ToString(); //get the file name of the posted image
        //                string type = FileUpload1.PostedFile.ContentType; //get the type of the posted image

        //                //Call the method to execute Insertion of data to the Database
        //                ExecuteInsert(theImage, type, length, fileName); //Big change here using the FileUpload.FileBytes property!
        //                lblResult.Text = "";
        //                lblResult.Text = "<br>";
        //                lblResult.Text += "File Content Type: " +
        //                 FileUpload1.PostedFile.ContentType + "<br>";
        //                lblResult.Text += "File Size: " +
        //                 FileUpload1.PostedFile.ContentLength + "kb<br>";
        //                lblResult.Text += "File Name: " +
        //                 FileUpload1.PostedFile.FileName + "<br>";

        //                lblResult.Text += "Saved Successfully!";
        //                //GridView1.DataBind();

        //            }
        //        }
        //        catch (Exception Ex)
        //        {
        //            lblResult.Text += "Error: <br>" + Ex.Message;
        //        }

        //    }
        //}

1 Answer, 1 is accepted

Sort by
0
Veselin Vasilev
Telerik team
answered on 06 Nov 2009, 02:40 PM
Hi mathieu cupryk,

Instead of using FileUpload1.PostedFile you can use

Request.Files[0]

This will work with both FileUpload and RadUpload

Kind regards,
Veselin Vasilev
the Telerik team

Instantly find answers to your questions on the new Telerik Support Portal.
Watch a video on how to optimize your support resource searches and check out more tips on the blogs.
Tags
Upload (Obsolete)
Asked by
mathieu cupryk
Top achievements
Rank 1
Answers by
Veselin Vasilev
Telerik team
Share this question
or