Downloading files that can be shown by the browser

12 posts, 0 answers
  1. Cristian Apavaloaiei
    Cristian Apavaloaiei avatar
    25 posts
    Member since:
    Aug 2008

    Posted 13 Jul 2010 Link to this post

    Hello,
    We've started using the FileExplorer to manage files inside our company, what we usually need is simple uploading and downloading. What's the correct way to handle file downloads? Is it with the open method? Because in that case when for example i try to download an .xml file, the browser knows how to interpret the file and it's shown to me in a radwindow. What i want is for it to be downloaded to my computer, but i can't use the usual 'save target as' context menu item as i would usually do to download such a file. The only way we've found until now to handle such files is to zip them beforehand, but it's very inconvenient. Could you point me to a better way to handle this scenario?

    Thank you
  2. Fiko
    Admin
    Fiko avatar
    1406 posts

    Posted 14 Jul 2010 Link to this post

    Hello Cristian,

    The file download feature is not related to RadFileExplorer control.You need to implement your own code that will explicitly force the browser to download the files, instead of opening them for preview and this online demo shows the exact steps in order to achieve the desired result. In addition, I recommend you to check the "FORCE THE BROWSER TO DOWNLOAD THE FILES"  section of this KB article for more information on the subject. More details about MIME types can be found here.

    I hope this helps.

    Regards,
    Fiko
    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. UI for ASP.NET Ajax is Ready for VS 2017
  4. Cristian Apavaloaiei
    Cristian Apavaloaiei avatar
    25 posts
    Member since:
    Aug 2008

    Posted 16 Jul 2010 Link to this post

    Hello,
    I've looked at your code samples, and i added a script file with the OnClientFileOpen and referenced it through the <head></head> tag of the page (the reason being that i'm using a sitefinity website, and the FileExplorer is inside a user control).
    This is how i then modified the FileExplorer to look like:
    <telerik:RadFileExplorer ID="FileExplorer" runat="server" Skin="Black" EnableOpenFile="true" OnClientFileOpen="OnClientFileOpen">
        <Configuration ViewPaths="~/Downloads/" MaxUploadFileSize="10000000" />
    </telerik:RadFileExplorer>
    The problem now is that the files are no longer shown. By deleting the OnClientFileOpen property the files are shown again. Any help would be appreciated.

    Thank you
  5. Petio Petkov
    Admin
    Petio Petkov avatar
    825 posts

    Posted 20 Jul 2010 Link to this post

    Hi Cristian,

    Could you please enable script debugging and send us the JavaScript error if such one appears?

    Note that you should add client-side handler too as it shown in the following online example.
    "When a file is opened (double click on it), the extension of that file is checked inside the OnClientFileOpen event handler and in case that it is a 'jpg' or 'gif' file the event is canceled. The file is opened for direct download and not inside a preview window. The files are stored in a folder on the server and the downloaded file is served by the content-streamer - Handler.ashx file. Please note that the EnableFileOpen property needs to be set to "true" (it is "true" by default)."


    All the best,
    Petio Petkov
    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
  6. Marco
    Marco avatar
    22 posts
    Member since:
    Jan 2009

    Posted 28 Jul 2010 Link to this post

    The online example you mention does not work with windows filename.
    Is there some form of URLEncode you could recommend?
  7. Fiko
    Admin
    Fiko avatar
    1406 posts

    Posted 02 Aug 2010 Link to this post

    Hi Marco,

    You can use window.escape method. more details about that method can be found on this page.


    Kind regards,
    Fiko
    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
  8. Thomas
    Thomas avatar
    8 posts
    Member since:
    Aug 2010

    Posted 13 Aug 2010 Link to this post

    When I tried the method described in the sample code, I get the error message "The resource cannot be found" on the file Handler.ashx.

    Is Handler.ashx built into the ASP.NET framework or Telerik framework?  Where I can add it?
  9. Fiko
    Admin
    Fiko avatar
    1406 posts

    Posted 18 Aug 2010 Link to this post

    Hi Thomas,

    I have already answered your question in this forum thread.

    Sincerely yours,
    Fiko
    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
  10. David Brenchley
    David  Brenchley avatar
    67 posts
    Member since:
    Jun 2010

    Posted 24 Sep 2010 Link to this post

    This online demo that you link to
    http://demos.telerik.com/aspnet-ajax/fileexplorer/examples/filteranddownloadfiles/defaultcs.aspx
    in this forum and in the KB article does NOT exist.  Please provide us with a working link.
  11. Fiko
    Admin
    Fiko avatar
    1406 posts

    Posted 29 Sep 2010 Link to this post

    Hello David ,

    The demo's URL has being changed and now you can find it here.

    Regards,
    Fiko
    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
  12. Karl Wilkens
    Karl Wilkens avatar
    206 posts
    Member since:
    Oct 2012

    Posted 11 Oct 2010 Link to this post

    The samples for this issue no longer come up on the server - an error displays. I really need this to resolve a client issue (forcing a download of xml). Thanks.
  13. Fiko
    Admin
    Fiko avatar
    1406 posts

    Posted 14 Oct 2010 Link to this post

    Hi Karl,

    I have attached a project which shows how to force download for XML files.

    Best wishes,
    Fiko
    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
Back to Top
UI for ASP.NET Ajax is Ready for VS 2017