帝国CMS模板大全
www.admin99.cn
www.92cms.cn 帝国CMS模板下载站!,情怀,养站,二次开发!源码需求比较大的一站式会员下载,价更省!!!

php swfupload中文乱码怎么解决

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

本教程操作环境: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中文乱码怎么解决的详细内容!

赞(0)
版权声明:本文采用知识共享 署名4.0国际许可协议 [BY-NC-SA] 进行授权
文章名称:《php swfupload中文乱码怎么解决》
文章链接:https://www.admin99.cn/7292
本站资源仅供个人学习交流,请于下载后24小时内删除,不允许用于商业用途,否则法律问题自行承担。
QQ站长交流群:953950264

登录

找回密码

注册