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

Getting uploading files in server side

8 Answers 173 Views
AsyncUpload
This is a migrated thread and some comments may be shown as answers.
MTs
Top achievements
Rank 1
MTs asked on 28 Dec 2011, 10:24 AM
Is there a way to get uploading files in server side?

I know I can get uploaded files thru AsyncUpload1.UploadedFiles, but I want the currently uploading files.

Thanks,
MTs

8 Answers, 1 is accepted

Sort by
0
Shinu
Top achievements
Rank 2
answered on 28 Dec 2011, 01:59 PM
Hello,

You can access the uploaded files as described in the following help document.
OnFileUploaded.

Thanks,
Shinu.
0
Bozhidar
Telerik team
answered on 29 Dec 2011, 01:01 PM
Hi,

Unfortunately you won't be able to access the files that are still uploading. RadAsyncUpload uploads the files asynchronously and doesn't cause a postback to the page. If a page postback occurs while a file is being uploaded, the upload will fail.

All the best,
Bozhidar
the Telerik team
If you want to get updates on new releases, tips and tricks and sneak peeks at our product labs directly from the developers working on the RadControls for ASP.NET AJAX, subscribe to their blog feed now
0
MTs
Top achievements
Rank 1
answered on 01 Jan 2012, 09:59 AM
Bozhidar, thanks for your answer.
1. I can do partial postback and then the upload won't fail.
2. Is there a way to get uploading file's temp name in javascript? not the real name - just the temp name as it's stored in the temp directory.
0
Bozhidar
Telerik team
answered on 03 Jan 2012, 10:57 AM
Hi,

You are right, during a partial postback the upload doesn't fail, but you still don't have access to the uploading files. 

You can get the temp file name, but only when the file is already uploaded. In order to do that you have to extend the Upload's handler, as shown in this demo. There, instead of ImageID you should add a property tempFileName and set it in the overridden  Process function in Handler.ashx.cs.

During the uploading process you can only get the real file name in the client's OnClientFileUploading event, like so:

function onClientFileUploading(sender, args) {
    alert(args.get_fileName());
}
Greetings,
Bozhidar
the Telerik team
If you want to get updates on new releases, tips and tricks and sneak peeks at our product labs directly from the developers working on the RadControls for ASP.NET AJAX, subscribe to their blog feed now
0
MTs
Top achievements
Rank 1
answered on 03 Jan 2012, 11:36 AM
Hi Bozhidar.  
The problem is that the filename is not unique.
I need an unique key for each file that I can access from web (C#) and from client (javascript).
The index is also not unique because it can change when removing files.

Is there something like that?


0
Bozhidar
Telerik team
answered on 03 Jan 2012, 05:16 PM
Hi,

As I said previously you have access to the temp file name, which is unique, in the Process function in the file Handler.ashx.cs (in the shown demo). If you add a property called tempFileName in the SampleAsyncUploadResult.cs file, you can set it in the aforementioned function in the following way:

protected override IAsyncUploadResult Process(UploadedFile file, HttpContext context,
    IAsyncUploadConfiguration configuration, string tempFileName)
{
    SampleAsyncUploadResult result = CreateDefaultUploadResult<SampleAsyncUploadResult>(file);
    result.TempFileName = tempFileName;
    ...
}

Then you can get this property from javascript:
function fileUploaded(sender, args) {
    var tempName = args.get_fileInfo().tempFileName;
}

or from C# in code behind:
protected void RadAsyncUpload1_FileUploaded(object sender, Telerik.Web.UI.FileUploadedEventArgs e)
{
    SampleAsyncUploadResult result = e.UploadResult as SampleAsyncUploadResult;
    string tempFileName = result.TempFileName;
}

All the best,
Bozhidar
the Telerik team
If you want to get updates on new releases, tips and tricks and sneak peeks at our product labs directly from the developers working on the RadControls for ASP.NET AJAX, subscribe to their blog feed now
0
MTs
Top achievements
Rank 1
answered on 04 Jan 2012, 01:47 PM
Bozhidar, I want the unique key (temp file name or somthing else) when document uploading.
Not after it was uploaded.
0
Bozhidar
Telerik team
answered on 04 Jan 2012, 05:54 PM
Hello,

As I said previously, during the uploading process you can only get the real file name in the client's OnClientFileUploading event handler function.

Kind regards,
Bozhidar
the Telerik team
If you want to get updates on new releases, tips and tricks and sneak peeks at our product labs directly from the developers working on the RadControls for ASP.NET AJAX, subscribe to their blog feed now
Tags
AsyncUpload
Asked by
MTs
Top achievements
Rank 1
Answers by
Shinu
Top achievements
Rank 2
Bozhidar
Telerik team
MTs
Top achievements
Rank 1
Share this question
or