Working with files on the client side

7 posts, 0 answers
  1. JDT
    JDT avatar
    45 posts
    Member since:
    Jul 2007

    Posted 25 May 2010 Link to this post

    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; 

  2. Tina Stancheva
    Admin
    Tina Stancheva avatar
    3298 posts

    Posted 28 May 2010 Link to this post

    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.
  3. DevCraft banner
  4. JDT
    JDT avatar
    45 posts
    Member since:
    Jul 2007

    Posted 28 May 2010 Link to this post

    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!
  5. Stan
    Stan avatar
    1 posts
    Member since:
    Oct 2010

    Posted 07 Feb 2011 Link to this post

    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
  6. Genady Sergeev
    Admin
    Genady Sergeev avatar
    1596 posts

    Posted 10 Feb 2011 Link to this post

    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>>
  7. Gurpreet Singh
    Gurpreet Singh avatar
    16 posts
    Member since:
    Jan 2010

    Posted 17 Oct 2012 Link to this post

    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
     
  8. Tina Stancheva
    Admin
    Tina Stancheva avatar
    3298 posts

    Posted 18 Oct 2012 Link to this post

    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.

Back to Top
DevCraft banner