首页 >后端开发 >PHP问题 > 正文

php swfupload中文乱码怎么解决

原创2021-05-21 16:45:2201526

方法: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中文乱码怎么解决的详细内容,更多请关注php中文网其它相关文章!

php中文网最新课程二维码

声明:本文原创发布php中文网,转载请注明出处,感谢您的尊重!如有疑问,请联系admin@php.cn处理

  • 相关标签:SWFUpload 中文乱码
  • 相关文章

    相关视频


    网友评论

    文明上网理性发言,请遵守 新闻评论服务协议

    我要评论
  • 专题推荐

    作者信息

    青灯夜游

    今天学习一小步,明天提升一大步

    最近文章
    vue开发工具有哪些371
    vue路由跳转方式有哪些895
    vue怎么设置样式936
    推荐视频教程
  • php mysql实战:学生信息管理系统(玉女心经版)php mysql实战:学生信息管理系统(玉女心经版)
  • ThinkPHP5.1企业站点快速开发ThinkPHP5.1企业站点快速开发
  • PHP安全与漏洞PHP安全与漏洞
  • PHP开发基础之语法篇PHP开发基础之语法篇
  • PHP开发基础之数组篇PHP开发基础之数组篇
  • 视频教程分类