方法: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中文乱码怎么解决的详细内容。