« Javascript防阻代码YAHOO YUI2工具库 »

关于文件下载那点事

 没啥好说的。关键代码:

// Set the headers. res.setContentType("application/x-download");

res.setHeader("Content-Disposition", "attachment; filename=" + filename);

 // Send the file. OutputStream out = res.getOutputStream(  );

returnFile(filename, out);  // Shown earlier in the chapter

 

3. Microsoft documents Internet Explorer's deviant behavior, although I've found that reality doesn't exactly match the documentation.

4. The HTTP specification recommends setting the Content-Type to application/octet-stream. Unfortunately, this causes problems with Opera 6 on Windows (which will display the raw bytes for any file whose extension it doesn't recognize) and on Internet Explorer 5.1 on the Mac (which will display inline content that would be downloaded if sent with an unrecognized type).

文件名问题就以url来做。上面英文中 有提到。

http://onjava.com/pub/a/onjava/excerpt/jebp_3/index3.html#ex3-9

 

 

  • 相关文章:

发表评论:

◎欢迎参与讨论,请在这里发表您的看法、交流您的观点。

日历

最新评论及回复

最近发表

Powered By Z-Blog 1.8 Arwen Build 81206

湘 ICP 备 06003756 号
Copyright 山寨 Rights Reserved.