社区
Web 开发
帖子详情
SmartUpload 不能下载中文名的文件.怎么解决啊?
姓庄滴
2006-04-01 09:44:21
用SmartUpload 的downloadFile()方法下载文件...
如果所下载的文件是以"字母命名",就可以正常下载.
那么如果所下载文件是以"中文命名",就不行了..
怎么解决啊?
或者有没有其它下载文件的方法?
或者,怎么在处理上传文件时,改变所上传文件的名字.
...全文
262
4
打赏
收藏
SmartUpload 不能下载中文名的文件.怎么解决啊?
用SmartUpload 的downloadFile()方法下载文件... 如果所下载的文件是以"字母命名",就可以正常下载. 那么如果所下载文件是以"中文命名",就不行了.. 怎么解决啊? 或者有没有其它下载文件的方法? 或者,怎么在处理上传文件时,改变所上传文件的名字.
复制链接
扫一扫
分享
转发到动态
举报
写回复
配置赞助广告
用AI写文章
4 条
回复
切换为时间正序
请发表友善的回复…
发表回复
打赏红包
kkgrubby
2006-04-03
打赏
举报
回复
谁能贴个下载的代码啊
我怎么老是下载本身页面呢
woolceo
2006-04-01
打赏
举报
回复
发了.
姓庄滴
2006-04-01
打赏
举报
回复
朋友, 我给你发了站内消息了.你收到没有?我的邮箱是:zhuangnet@163.com
请你把你的QQ留给我,我得谢你才行.
woolceo
2006-04-01
打赏
举报
回复
我这有解决了中文问题的smartupload.jar文件...
楼主PM我,顺便留下邮箱...
Smart
Upload
上传组件(中文终极
解决
版) JDK1.6
许多朋友反应使用后,出现Bad Version的问题,现在跟大家说明一下,我这个版本编译器是jdk1.6的,所以你们在使用的时候也请选择jdk1.6的编译器,否则会出现bad version的问题。 其他版本: jdk1.4 http://download.csdn.net/source/861329 jdk1.5 http://download.csdn.net/source/875558 (中文终极
解决
版,包括中文
文件
名上传后乱码,中文参数,
下载
) 经过呕心沥血的一天一夜,终于搞定
Smart
Upload
组件的所有中文问题,为大家去除有史以来最头痛的中文问题,包括中文参数,中文
文件
名上传后服务器端
文件
名乱码问题,以及中文
文件
名
下载
问题。 这是我的中文
解决
终极版。欢迎大家
下载
!
下载
后,放到tomcat等服务器的lib目录中即可,也可以改名为jsp
smart
upload
.jar(或任意名字) ★★注意:该
文件
是jar类型,如果
下载
下来不是jar类型,比如zip,则需要将zip改为jar类型,本人测试了一下好像迅雷
下载
会造成
文件
名被改成zip类型,所以请大家注意一下。 使用说明: 默认编码为UTF-8,若您的系统是其他编码的,请选用我的指定编码函数: 1.上传默认方法
upload
(),指定编码使用
upload
("编码名称"); 2.
下载
默认方法downloadFile("要
下载
的
文件
路径"),指定编码使用downloadFile("要
下载
的
文件
路径", "编码名称")。
Smart
Upload
用于JDK1.4(中文终极
解决
版,包括中文
文件
名上传后乱码,中文参数,
下载
)
这个版本可以支持jdk1.4及以上环境。 其他版本: jdk1.5 http://download.csdn.net/source/875558 jdk1.6 http://download.csdn.net/source/640739
Smart
Upload
上传组件(中文终极
解决
版,包括中文
文件
名上传后乱码,中文参数,
下载
) 经过呕心沥血的一天一夜,终于搞定
Smart
Upload
组件的所有中文问题,为大家去除有史以来最头痛的中文问题,包括中文参数,中文
文件
名上传后服务器端
文件
名乱码问题,以及中文
文件
名
下载
问题。 这是我的中文
解决
终极版。欢迎大家
下载
!
下载
后,放到tomcat等服务器的lib目录中即可,也可以改名为jsp
smart
upload
.jar(或任意名字) 使用说明: 默认编码为UTF-8,若您的系统是其他编码的,请选用我的指定编码函数: 1.上传默认方法
upload
(),指定编码使用
upload
("编码名称"); 2.
下载
默认方法downloadFile("要
下载
的
文件
路径"),指定编码使用downloadFile("要
下载
的
文件
路径", "编码名称")。
jsp
smart
upload
上传
下载
,已修改过源代码!
解决
jsp
smart
upload
上传
文件
中文乱码 采用jsp
smart
upload
上传
文件
时,如果
文件
名含有中文,在服务器端取得
文件
名是会出现乱码。如果表单项中填写了中文,一样会有乱码问题。看了下jsp
smart
upload
的源码,改了两个地方,现在可以没有乱码问题了。 第一个地方,修改类
Smart
Upload
中的
upload
()方法 // //这次用jsp
Smart
Upload
做
文件
上传
下载
, //该组件默认是GBK编码,当上传的
文件
名为中文时, //我将
文件
名getBytes()下,将GBK改成UTF-8。测试了下,貌似没问题, //突然有一次上传一
文件
时,发现最后几个字乱码,一直是??。在拿些
文件
测试, // 后来知道了是当
文件
名为中文奇数时,会乱码,而且还上传不了。 // 再做测试,找原因,查看字符的长度,转成16进制看结果。觉得是jsp
Smart
Upload
组件对中文支持不足的问题。 http://ru-yi86.javaeye.com/blog/368553 Java代码 1. public void
upload
() 2. throws
Smart
Upload
Exception, IOException, ServletException 3. { 4. int totalRead = 0; 5. int readBytes = 0; 6. long totalFileSize = 0L; 7. boolean found = false; 8. String dataHeader = new String(); 9. String fieldName = new String(); 10. String fileName = new String(); 11. String fileExt = new String(); 12. String filePathName = new String(); 13. String contentType = new String(); 14. String contentDisp = new String(); 15. String typeMIME = new String(); 16. String subTypeMIME = new String(); 17. boolean isFile = false; 18. m_totalBytes = m_request.getContentLength(); 19. m_binArray = new byte[m_totalBytes]; 20. for(; totalRead < m_totalBytes; totalRead += readBytes) 21. try 22. { 23. m_request.getInputStream(); 24. readBytes = m_request.getInputStream().read(m_binArray, totalRead, m_totalBytes - totalRead); 25. } 26. catch(Exception e) 27. { 28. throw new
Smart
Upload
Exception("Unable to
upload
."); 29. } 30. 31. for(; !found && m_currentIndex < m_totalBytes; m_currentIndex++) 32. if(m_binArray[m_currentIndex] == 13) 33. found = true; 34. else 35. m_boundary = m_boundary + (char)m_binArray[m_currentIndex]; 36. 37. if(m_currentIndex == 1) 38. return; 39. m_currentIndex++; 40. do 41. { 42. if(m_currentIndex >= m_totalBytes) 43. break; 44. dataHeader = getDataHeader(); 45. m_currentIndex = m_currentIndex + 2; 46. isFile = dataHeader.indexOf("filename") > 0; 47. fieldName = getDataFieldValue(dataHeader, "name"); 48. if(isFile) 49. { 50. filePathName = getDataFieldValue(dataHeader, "filename"); 51. fileName = getFileName(filePathName); 52. fileExt = getFileExt(fileName); 53. contentType = getContentType(dataHeader); 54. contentDisp = getContentDisp(dataHeader); 55. typeMIME = getTypeMIME(contentType); 56. subTypeMIME = getSubTypeMIME(contentType); 57. } 58. getDataSection(); 59. if(isFile && fileName.length() > 0) 60. { 61. if(m_deniedFilesList.contains(fileExt)) 62. throw new SecurityException("The extension of the file is denied to be
upload
ed (1015)."); 63. if(!m_allowedFilesList.isEmpty() && !m_allowedFilesList.contains(fileExt)) 64. throw new SecurityException("The extension of the file is not allowed to be
upload
ed (1010)."); 65. if(m_maxFileSize > (long)0 && (long)((m_endData - m_startData) + 1) > m_maxFileSize) 66. throw new SecurityException(String.valueOf((new StringBuffer("Size exceeded for this file : ")).append(fileName).append(" (1105)."))); 67. totalFileSize += (m_endData - m_startData) + 1; 68. if(m_totalMaxFileSize > (long)0 && totalFileSize > m_totalMaxFileSize) 69. throw new SecurityException("Total File Size exceeded (1110)."); 70. } 71. if(isFile) 72. { 73. com.jsp
smart
.
upload
.File newFile = new com.jsp
smart
.
upload
.File(); 74. newFile.setParent(this); 75. newFile.setFieldName(fieldName); 76. newFile.setFileName(fileName); 77. newFile.setFileExt(fileExt); 78. newFile.setFilePathName(filePathName); 79. newFile.setIsMissing(filePathName.length() == 0); 80. newFile.setContentType(contentType); 81. newFile.setContentDisp(contentDisp); 82. newFile.setTypeMIME(typeMIME); 83. newFile.setSubTypeMIME(subTypeMIME); 84. if(contentType.indexOf("application/x-macbinary") > 0) 85. m_startData = m_startData + 128; 86. newFile.setSize((m_endData - m_startData) + 1); 87. newFile.setStartData(m_startData); 88. newFile.setEndData(m_endData); 89. m_files.addFile(newFile); 90. } else 91. { 92. /** 93. * 原来的代码 94. * String value = new String(m_binArray, m_startData, (m_endData - m_startData) + 1); 95. */ 96. /** 97. *
解决
取得request的参数的中文编码问题 98. */ 99. String value = new String(m_binArray, m_startData, (m_endData - m_startData) + 1, "utf-8"); 100. 101. 102. m_formRequest.putParameter(fieldName, value); 103. } 104. if((char)m_binArray[m_currentIndex + 1] == '-') 105. break; 106. m_currentIndex = m_currentIndex + 2; 107. } while(true); 108. } 第二个地方,修改类
Smart
Upload
中的getDataHeader()方法 : Java代码 1. private String getDataHeader() 2. { 3. int start = m_currentIndex; 4. int end = 0; 5. int len = 0; 6. boolean found = false; 7. while(!found) 8. if(m_binArray[m_currentIndex] == 13 && m_binArray[m_currentIndex + 2] == 13) 9. { 10. found = true; 11. end = m_currentIndex - 1; 12. m_currentIndex = m_currentIndex + 2; 13. } else 14. { 15. m_currentIndex++; 16. } 17. 18. 19. //原始代码 20. //String dataHeader = new String(m_binArray, start, (end - start) + 1); 21. /** 22. *
解决
文件
名的中文乱码问题 23. */ 24. String dataHeader = null; 25. try { 26. dataHeader = new String(m_binArray, start, (end - start) + 1,"utf-8"); 27. } catch (UnsupportedEncodingException e) { 28. e.printStackTrace(); 29. } 30. return dataHeader; 31. }
Smart
Upload
用于JDK1.5(中文终极
解决
版,包括中文
文件
名上传后乱码,中文参数,
下载
)
这个版本可以支持jdk1.5环境。 其他版本: jdk1.4 http://download.csdn.net/source/861329 jdk1.6 http://download.csdn.net/source/640739
Smart
Upload
上传组件(中文终极
解决
版,包括中文
文件
名上传后乱码,中文参数,
下载
) 经过呕心沥血的一天一夜,终于搞定
Smart
Upload
组件的所有中文问题,为大家去除有史以来最头痛的中文问题,包括中文参数,中文
文件
名上传后服务器端
文件
名乱码问题,以及中文
文件
名
下载
问题。 这是我的中文
解决
终极版。欢迎大家
下载
!
下载
后,放到tomcat等服务器的lib目录中即可,也可以改名为jsp
smart
upload
.jar(或任意名字) 使用说明: 默认编码为UTF-8,若您的系统是其他编码的,请选用我的指定编码函数: 1.上传默认方法
upload
(),指定编码使用
upload
("编码名称"); 2.
下载
默认方法downloadFile("要
下载
的
文件
路径"),指定编码使用downloadFile("要
下载
的
文件
路径", "编码名称")。
Smart
Upload
上传组件(中文终极
解决
版,包括中文
文件
名上传后乱码,中文参数,
下载
),JDK 1.6
许多朋友反应使用后,出现Bad Version的问题,现在跟大家说明一下,我这个版本编译器是jdk1.6的,所以你们在使用的时候也请选择jdk1.6的编译器,否则会出现bad version的问题。 其他版本: jdk1.4 http://download.csdn.net/source/861329 jdk1.5 http://download.csdn.net/source/875558
Smart
Upload
上传组件(中文终极
解决
版,包括中文
文件
名上传后乱码,中文参数,
下载
) 经过呕心沥血的一天一夜,终于搞定
Smart
Upload
组件的所有中文问题,为大家去除有史以来最头痛的中文问题,包括中文参数,中文
文件
名上传后服务器端
文件
名乱码问题,以及中文
文件
名
下载
问题。 这是我的中文
解决
终极版。欢迎大家
下载
!
下载
后,放到tomcat等服务器的lib目录中即可,也可以改名为jsp
smart
upload
.jar(或任意名字) 使用说明: 默认编码为UTF-8,若您的系统是其他编码的,请选用我的指定编码函数: 1.上传默认方法
upload
(),指定编码使用
upload
("编码名称"); 2.
下载
默认方法downloadFile("要
下载
的
文件
路径"),指定编码使用downloadFile("要
下载
的
文件
路径", "编码名称")。
Web 开发
81,094
社区成员
341,711
社区内容
发帖
与我相关
我的任务
Web 开发
Java Web 开发
复制链接
扫一扫
分享
社区描述
Java Web 开发
社区管理员
加入社区
获取链接或二维码
近7日
近30日
至今
加载中
查看更多榜单
社区公告
暂无公告
试试用AI创作助手写篇文章吧
+ 用AI写文章