Force download popup for audio file
-
Hi all, I'm working on a website that allows users to download audio files, the problem is that when i use a regular link with href=fileURL, this usually plays the audio file using the installed audio player. I want a method to force download dialog box to open. (Also i don't want to put the audio in .zip file and so on...) Thanks.
-
Hi all, I'm working on a website that allows users to download audio files, the problem is that when i use a regular link with href=fileURL, this usually plays the audio file using the installed audio player. I want a method to force download dialog box to open. (Also i don't want to put the audio in .zip file and so on...) Thanks.
# string strRequest = Request.QueryString("file"); # //-- if something was passed to the file querystring # if (strRequest != "") { # //get absolute path of the file # string path = Server.MapPath(strRequest); # //get file object as FileInfo # System.IO.FileInfo file = new System.IO.FileInfo(path); # //-- if the file exists on the server # if (file.Exists) { # //set appropriate headers # Response.Clear(); # Response.AddHeader("Content-Disposition", "attachment; filename=" + file.Name); # Response.AddHeader("Content-Length", file.Length.ToString()); # Response.ContentType = "application/octet-stream"; # Response.WriteFile(file.FullName); # Response.End(); # //if file does not exist # } # else { # Response.Write("This file does not exist."); # }
I didn't get any requirements for the signature
-
# string strRequest = Request.QueryString("file"); # //-- if something was passed to the file querystring # if (strRequest != "") { # //get absolute path of the file # string path = Server.MapPath(strRequest); # //get file object as FileInfo # System.IO.FileInfo file = new System.IO.FileInfo(path); # //-- if the file exists on the server # if (file.Exists) { # //set appropriate headers # Response.Clear(); # Response.AddHeader("Content-Disposition", "attachment; filename=" + file.Name); # Response.AddHeader("Content-Length", file.Length.ToString()); # Response.ContentType = "application/octet-stream"; # Response.WriteFile(file.FullName); # Response.End(); # //if file does not exist # } # else { # Response.Write("This file does not exist."); # }
I didn't get any requirements for the signature