>  기사  >  백엔드 개발  >  PHP swfupload에서 중국어 왜곡 코드를 해결하는 방법

PHP swfupload에서 중국어 왜곡 코드를 해결하는 방법

青灯夜游
青灯夜游원래의
2021-05-21 16:45:222379검색

방법: 1. "fileName=new String(fileName.getBytes("UTF-8"), "GBK")" 문을 사용합니다. 2. "fileName=URLDecoder.decode(fileName, "UTF-8")을 사용합니다. " 성명.

PHP swfupload에서 중국어 왜곡 코드를 해결하는 방법

이 튜토리얼의 운영 환경: Windows 7 시스템, PHP 버전 7.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;
}

실제 사용

fileName = URLDecoder.decode(fileName,"UTF-8");

권장 학습: "PHP 비디오 튜토리얼"

위 내용은 PHP swfupload에서 중국어 왜곡 코드를 해결하는 방법의 상세 내용입니다. 자세한 내용은 PHP 중국어 웹사이트의 기타 관련 기사를 참조하세요!

성명:
본 글의 내용은 네티즌들의 자발적인 기여로 작성되었으며, 저작권은 원저작자에게 있습니다. 본 사이트는 이에 상응하는 법적 책임을 지지 않습니다. 표절이나 침해가 의심되는 콘텐츠를 발견한 경우 admin@php.cn으로 문의하세요.