有的時候我們不想讓用戶直接在ie中打開已知類型的文件,比如word,而希望能直接下載,這時候可用下面代碼來替換response.redirect
response.contenttype = "application/octet-stream";
response.addheader("content-disposition", "attachment;filename="+httputility.urlencode(yourfilename,response.headerencoding ));
response.binarywrite((byte[])yourfiledata.rows[0]["attachmentcontent"]);
response.end();
用httputility.urlencode可以解決中文文件名亂碼問題。
新聞熱點
疑難解答
圖片精選