php swfupload中文乱码怎么解决

青灯夜游
发布: 2023-03-09 20:44:02
原创
2394 人浏览过

方法:1、利用“fileName=new String(fileName.getBytes("UTF-8"),"GBK")”语句;2、利用“fileName=URLDecoder.decode(fileName,"UTF-8")”语句。

php swfupload中文乱码怎么解决

本教程操作环境:windows7系统、PHP7.1版,DELL G3电脑

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");
登录后复制

推荐学习:《PHP视频教程

以上是php swfupload中文乱码怎么解决的详细内容。更多信息请关注PHP中文网其他相关文章!

相关标签:
来源:php.cn
本站声明
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系admin@php.cn
热门教程
更多>
最新下载
更多>
网站特效
网站源码
网站素材
前端模板
关于我们 免责声明 Sitemap
PHP中文网:公益在线PHP培训,帮助PHP学习者快速成长!