3 Answers, 1 is accepted
0
Hi Kjell,
To download files instead of open them you need to pass the files as an attachment through the content provider's handler. Please review the following live demo demonstrating such implementation:
http://demos.telerik.com/aspnet-ajax/fileexplorer/examples/applicationscenarios/filteranddownloadfiles/defaultcs.aspx
Regards,
Dobromir
Telerik
To download files instead of open them you need to pass the files as an attachment through the content provider's handler. Please review the following live demo demonstrating such implementation:
http://demos.telerik.com/aspnet-ajax/fileexplorer/examples/applicationscenarios/filteranddownloadfiles/defaultcs.aspx
Regards,
Dobromir
Telerik
If you want to get updates on new releases, tips and tricks and sneak peeks at our product labs directly from the developers working on the UI for ASP.NET AJAX, subscribe to the blog feed now.
0
Kjell
Top achievements
Rank 1
Iron
answered on 07 Feb 2014, 01:10 PM
It works for all file extensions in addition to pictures. This will open the image in the browser. I want to get the dialog to download the image. See attached Open.png that I get with other file extensions.
Open.png
var requestImage = "Handler.ashx?path=" + item.get_url(); does not work, get double Handler.ashx? path ....
this works: var requestImage = item.get_url();
http://www.junis.net/test/FileExplorer.aspx
Open.png
var requestImage = "Handler.ashx?path=" + item.get_url(); does not work, get double Handler.ashx? path ....
this works: var requestImage = item.get_url();
function OnClientFileOpen(oExplorer, args) {
var item = args.get_item();
var fileExtension = item.get_extension();
if (fileExtension == "jpg" || fileExtension == "gif" || fileExtension == "png" || fileExtension == "pdf") {
args.set_cancel(true);
// var requestImage = "Handler.ashx?path=" + item.get_url(); This not work.....
var requestImage = item.get_url();
document.location = requestImage;
}
}
http://www.junis.net/test/FileExplorer.aspx
0
Hi Kjell,
FileExplorer is already using a generic handler when working with a DB provider, this is why it is enough to request directly the item by its url. The other thing you have to do is to implement the download logic from the handler from the demo to the one used in your application.
Commenting the following if statement in the Handler.ashx file will allow you to download all type of files:
I hope this helps.
Regards,
Veselina Raykova
Telerik
FileExplorer is already using a generic handler when working with a DB provider, this is why it is enough to request directly the item by its url. The other thing you have to do is to implement the download logic from the handler from the demo to the one used in your application.
Commenting the following if statement in the Handler.ashx file will allow you to download all type of files:
private
void
WriteFile(
byte
[] content,
string
fileName,
string
contentType, HttpResponse response)
{
response.Buffer =
true
;
response.Clear();
response.ContentType = contentType;
string
extension = System.IO.Path.GetExtension(fileName).ToLower();
//if (extension != ".htm" && extension != ".html" && extension != ".xml" && extension != ".jpg" && extension != ".gif" && extension != ".png")
//{
response.AddHeader(
"content-disposition"
,
"attachment; filename="
+ fileName);
//}
response.BinaryWrite(content);
response.Flush();
response.End();
}
I hope this helps.
Regards,
Veselina Raykova
Telerik
If you want to get updates on new releases, tips and tricks and sneak peeks at our product labs directly from the developers working on the UI for ASP.NET AJAX, subscribe to the blog feed now.