After you click Download to download an mp3 file, it will be played by Media Player and cannot be saved. it is inconvenient. After searching online for a long time, you can finally find a solution and post it to you.
Try
...{
Fullfilename = server. mappath (filename); // filename -- name of the file to be downloaded
Fileinfo downloadfile = new fileinfo (fullfilename );
If (downloadfile. exists)
...{
Response. Clear ();
Response. clearheaders ();
Response. Buffer = false;
Response. contenttype = "application/octet-stream ";
Response. appendheader ("content-disposition", "attachment; filename ="
+ Httputility. urlencode (downloadfile. fullname, system. Text. encoding. ASCII ));
Response. appendheader ("Content-Length", downloadfile. length. tostring ());
Response. WriteFile (DownloadFile. FullName );
Response. Flush ();
Response. End ();
}
Else
...{
// The file does not exist.
}
}
Catch
...{
// The file does not exist.
}
In addition, the answer to net_lover (Chapter E of Mencius) can only save the current URL file name. The following is the code. A dialog box with colors is displayed.
Onclick = "document.exe cCommand ('shanghaias ')"
<Input onclick = "a ()">
<Script>
SInitColor = null
Function ()
...{
If (sInitColor = null)
Var sColor = document. all. dlgHelper. ChooseColorDlg ();
Else
VaR scolor = Document. All. dlghelper. choosecolordlg (sinitcolor );
Scolor = scolor. tostring (16 );
If (scolor. length <6 )...{
VaR stempstring = "000000". substring (-scolor. Length );
Scolor = stempstring. Concat (scolor );
}
Scolor = "#" + scolor
Alert (sColor)
}
</Script>
<OBJECT id = dlgHelper CLASSID = "clsid: 3050f819-98b5-11cf-bb82-00aa00bdce0b" width = "0px" height = "0px"> </OBJECT>