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

Working with files on the client side

6 Answers 205 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.
JDT
Top achievements
Rank 1
JDT asked on 26 May 2010, 02:07 AM
Hi Telerik,

I wanted to access files to be uploaded on the client before uploading them. On both the FileuploadStarting event, and FileUploaded event I can not access the file. I get access denied exceptions and in FileUploadStarting, e.NewFileStream always returns null. What should I do?

I would prefer to access the file on "FileUploaded"

Thanks!

void RadUpload_FileUploadStarting(object sender, Telerik.Windows.Controls.FileUploadStartingEventArgs e) 
        { 
            FileStream fs = e.NewFileStream as FileStream; 

6 Answers, 1 is accepted

Sort by
0
Tina Stancheva
Telerik team
answered on 28 May 2010, 05:20 PM
Hello JDT,

You can use the e.SelectedFile property instead of the NewFileStream one. The SelectedFile will give you further access to the uploaded or uploading file. You can use it in both event handlers - FileUploaded and FileUploadStarting depending on your requirements:
private void RadUpload1_FileUploadStarting(object sender, FileUploadStartingEventArgs e)
{
    RadUploadSelectedFile file = e.SelectedFile as RadUploadSelectedFile;
    FileInfo FileInfo = file.File;
    String FileName = file.Name;
    long FileSize = file.Size;
}

I also attached a sample project illustrating this approach. Can you please take a look at it and let me know if this is what you had in mind?

Kind regards,
Tina Stancheva
the Telerik team

Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items.
0
JDT
Top achievements
Rank 1
answered on 28 May 2010, 11:42 PM
Thanks for the example. I added the following code and it worked...I have no idea why this wasn't working before.

e.SelectedFile.File.OpenRead(); 

Appreciate it!
0
Stan
Top achievements
Rank 1
answered on 07 Feb 2011, 10:07 AM
Hi,

I'm having trouble with the "FileUploadStartingEventArgs". I'm work with the RadUpload (Telerik version v.2010.3.1317.35) but I'm getting the message "Type 'FileUploadStartingEventArgs' is not defined". I can't figure out what I'm doing wrong. Could you please let me know.

Thsnks,

Stan
0
Genady Sergeev
Telerik team
answered on 10 Feb 2011, 03:32 PM
Hello Stan,

FileUploadStartingEventArgs event args are part of RadUpload for Silverlight. However, you seem to be using RadUpload for ASP.NET Ajax, which does not provide such events/event arguments.

Regards,
Genady Sergeev
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
Gurpreet Singh
Top achievements
Rank 1
answered on 17 Oct 2012, 06:37 AM
Hi,

I don't want to upload file on server. 
I just want to access file content on client side can I use RadUpload control without setting UploadServiceUrl (without handler file).

How can I do this ?

Thanks,
Gurpreet
 
0
Tina Stancheva
Telerik team
answered on 18 Oct 2012, 07:46 AM
Hi Gurpreet,

As the RadUpload control is designed to allow you to easily select and upload files on a server, it might be better to use the OpenFileDialog to open a file on the client-side and manipulate it as you need to.

All the best,
Tina Stancheva
the Telerik team

Explore the entire Telerik portfolio by downloading Telerik DevCraft Ultimate.

Tags
Upload
Asked by
JDT
Top achievements
Rank 1
Answers by
Tina Stancheva
Telerik team
JDT
Top achievements
Rank 1
Stan
Top achievements
Rank 1
Genady Sergeev
Telerik team
Gurpreet Singh
Top achievements
Rank 1
Share this question
or