php swfupload中文乱码怎么解决
3332
方法:1、利用“fileName=new String(fileName.getBytes("UTF-8"),"GBK")”语句;2、利用“fileName=URLDecoder.decode(fileName,"UTF-8")”语句。
SWFUpload中文乱码问题,在网上搜的帖子,关于这个问题的解决方法有很多。
第一种:
- fileName= new String(fileName.getBytes("UTF-8"),"GBK");
用这种方式能解决大部分乱码,但如果文件名中有特殊字符和标点符号有时候会转不过来。
第二种:我使用的是这种办法,测试已经通过
- /**在设置时需要设置一下上传事件
- *upload_start_handler : UploadStart,
- *动态传参数,解决文件名中文乱码问题
- **/
- function uploadStart(file) {
- try {
- /* I don't want to do any file validation or anything, I'll just update the UI and return true to indicate that the upload should start */
- var progress = new FileProgress(file, this.customSettings.progressTarget);
- //progress.setStatus("Uploading...");
- progress.setStatus("上传中...");
- progress.toggleCancel(true, this);
- this.setPostParams({
- 'fileName':encodeURIComponent(file.name)
- });
- }
- catch (ex) {
- }
- return true;
- }
在action中使用
- fileName = URLDecoder.decode(fileName,"UTF-8");
本文网址:https://www.zztuku.com/index.php/detail-8891.html
站长图库 - php swfupload中文乱码怎么解决
申明:如有侵犯,请 联系我们 删除。
您还没有登录,请 登录 后发表评论!
提示:请勿发布广告垃圾评论,否则封号处理!!