SampleHandlerUpload.ashx

5 posts, 1 answers
  1. Mazdak
    Mazdak avatar
    30 posts
    Member since:
    Nov 2010

    Posted 08 Feb 2011 Link to this post

    I'm trying to use Upload control but the sample code for this control is not complete. I can not find sample of SampleHandlerUpload.ashx .

    Regards
    Mazdak
  2. Answer
    Tina Stancheva
    Admin
    Tina Stancheva avatar
    3298 posts

    Posted 10 Feb 2011 Link to this post

    Hi Mazdak,

    The RadUpload is designed to work with a generic http handler on the server side. The events exposed by the RadUpload are for manipulating the RadUpload and the upload process before it has started. Once started, the upload will send http requests to the server and if you create a SampleUploadHandler that inherits the RadUploadHandler (like illustrated here), you will be able to upload files out-of-the-box.

    Only if you want to implement some custom behavior, you have to override some of the methods of the RadUploadHandler class and place your custom logic in them. You can fine more info here.

    Also, you can check out the examples added in our KnolwedgeBase, which illustrate the most common scenarios in which the RadUpload control is used.

    I hope this info will help you get started. However, if we can further assist you, please let us know.

    All the best,
    Tina Stancheva
    the Telerik team
    Let us know about your Windows Phone 7 application built with RadControls and we will help you promote it. Learn more>>
  3. DevCraft banner
  4. Marc Roussel
    Marc Roussel avatar
    429 posts
    Member since:
    Dec 2009

    Posted 18 Mar 2011 Link to this post

    Sorry but I don't get it either.  Where's the code example we have to put in the .ashx for getting the files from the controls and saving the, on a multiplefile upload ?

    Can't find anything
    That's what I call incomplete too.

    In your demo, you have the .xaml, the .cs but you should add the .ashx code that goes with it
  5. Marc Roussel
    Marc Roussel avatar
    429 posts
    Member since:
    Dec 2009

    Posted 18 Mar 2011 Link to this post

    I also tried to debug the context.Request and I don'T see any filename there that I've uploaded
    So how do you get the filename so you can use it to save the stream

    public void ProcessRequest(HttpContext context)
    {
        string filename = ?????;
      
        using (FileStream fs = File.Create("http://FooURL/Uploads/" + filename))
            SaveFile(context.Request.InputStream, fs);
    }
      
    private void SaveFile(Stream stream, FileStream fs)
    {
        byte[] buffer = new byte[4096];
        int bytesRead;
      
        while ((bytesRead = stream.Read(buffer, 0, buffer.Length)) != 0)
        {
            fs.Write(buffer, 0, bytesRead);
        }
    }
  6. Marc Roussel
    Marc Roussel avatar
    429 posts
    Member since:
    Dec 2009

    Posted 18 Mar 2011 Link to this post

    It's all right.  I did read the documentation and I saw that I had to add the RadUploadHandler as inheritence.
    and all the plumbing is done for me.
Back to Top
DevCraft banner