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

SampleHandlerUpload.ashx

4 Answers 121 Views
Upload
This is a migrated thread and some comments may be shown as answers.
This question is locked. New answers and comments are not allowed.
Mazdak
Top achievements
Rank 1
Mazdak asked on 08 Feb 2011, 05:24 PM
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

4 Answers, 1 is accepted

Sort by
0
Accepted
Tina Stancheva
Telerik team
answered on 10 Feb 2011, 02:18 PM
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>>
0
Marc Roussel
Top achievements
Rank 2
answered on 18 Mar 2011, 10:31 PM
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
0
Marc Roussel
Top achievements
Rank 2
answered on 18 Mar 2011, 10:43 PM
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);
    }
}
0
Marc Roussel
Top achievements
Rank 2
answered on 18 Mar 2011, 11:38 PM
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.
Tags
Upload
Asked by
Mazdak
Top achievements
Rank 1
Answers by
Tina Stancheva
Telerik team
Marc Roussel
Top achievements
Rank 2
Share this question
or