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

Downloading files that can be shown by the browser

11 Answers 393 Views
FileExplorer
This is a migrated thread and some comments may be shown as answers.
Cristian Apavaloaiei
Top achievements
Rank 2
Cristian Apavaloaiei asked on 13 Jul 2010, 09:14 AM
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

11 Answers, 1 is accepted

Sort by
0
Fiko
Telerik team
answered on 14 Jul 2010, 09:21 AM
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
0
Cristian Apavaloaiei
Top achievements
Rank 2
answered on 16 Jul 2010, 11:16 AM
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
0
Petio Petkov
Telerik team
answered on 20 Jul 2010, 12:16 PM
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
0
Marco
Top achievements
Rank 1
answered on 28 Jul 2010, 10:05 AM
The online example you mention does not work with windows filename.
Is there some form of URLEncode you could recommend?
0
Fiko
Telerik team
answered on 02 Aug 2010, 08:25 AM
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
0
Thomas
Top achievements
Rank 1
answered on 13 Aug 2010, 08:16 PM
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?
0
Fiko
Telerik team
answered on 18 Aug 2010, 03:54 PM
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
0
David Brenchley
Top achievements
Rank 1
answered on 24 Sep 2010, 06:19 PM
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.
0
Fiko
Telerik team
answered on 29 Sep 2010, 03:58 PM
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
0
Karl Wilkens
Top achievements
Rank 1
answered on 11 Oct 2010, 08:41 PM
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.
0
Fiko
Telerik team
answered on 14 Oct 2010, 03:49 PM
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
Tags
FileExplorer
Asked by
Cristian Apavaloaiei
Top achievements
Rank 2
Answers by
Fiko
Telerik team
Cristian Apavaloaiei
Top achievements
Rank 2
Petio Petkov
Telerik team
Marco
Top achievements
Rank 1
Thomas
Top achievements
Rank 1
David Brenchley
Top achievements
Rank 1
Karl Wilkens
Top achievements
Rank 1
Share this question
or