php swfupload中文亂碼怎麼解決

青灯夜游
發布: 2023-03-09 20:44:02
原創
2393 人瀏覽過

方法: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學習者快速成長!