I am making a website that downloads MP3 files (Legal ones ;-) )
Does anyone have an idea how to do it professionally. I mean, I don't want to make a link like
because, obviously, it creates lots of unwanted results, likw playing the MP3 instead of downloading it.
I got a code in C#, but I dont have a .NET framework. How can I do it in ASP .
here is the C# code I got, it may give you a hint. I is for downloading PDF files:
Does anyone have an idea how to do it professionally. I mean, I don't want to make a link like
Code:
<a href="folder/mymusic.mp3">My Music</a>
I got a code in C#, but I dont have a .NET framework. How can I do it in ASP .
here is the C# code I got, it may give you a hint. I is for downloading PDF files:
Code:
<%@ Page Language="C#" %>
<%@ Import Namespace="System.IO" %>
<HTML>
<HEAD>
<script runat="server" ID=Script1>
void Page_Load(object sender, System.EventArgs e) {
if (Page.IsPostBack){
FileStream MyFileStream = new FileStream(@"c:\samerhtml\test\sample.pdf", FileMode.Open);
long FileSize;
FileSize = MyFileStream.Length;
byte[] Buffer = new byte[(int)FileSize];
MyFileStream.Read(Buffer, 0, (int)MyFileStream.Length);
MyFileStream.Close();
Response.ContentType="application/pdf";
Response.AddHeader( "content-disposition","attachment; filename=MyPDF.PDF");
Response.BinaryWrite(Buffer);
}
}
</script>
</HEAD>
<body>
<form runat="server">
<asp:button id="link1" Text = "get PDF" runat="server" />
</form>
</body>
</HTML>