8 Answers, 1 is accepted
You can access the uploaded files as described in the following help document.
OnFileUploaded.
Thanks,
Shinu.
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
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.
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());
}
Bozhidar
the Telerik team
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?
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
Not after it was uploaded.
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