请教各位一个问题:
我写的一个ajax上传的函数
xhr.setRequestHeader("Content-Type", "multipart/form-data, boundary="+BOUNDARY);
xhr.setRequestHeader("Content-Length", file.fileSize);
var body = '';
body += "--" + BOUNDARY + "\r\n";
body += "Content-Disposition: form-data; name=\""+newName+ "\"; filename=\"" + newName+ "\"\r\n";
[color=red]如果这里两个地方有一个是中文的话就会出错,
[Exception... "String contains an invalid character" code: "5" nsresult: "0x80530005 (NS_ERROR_DOM_INVALID_CHARACTER_ERR)" location: "http://localhost:8088/TestUpload/upload.jsp Line: 255"]
我试过encodeURI(newName)来把newname的中文转码,但是在action就转不会中文了。
请各位dx指点一下,如何把newName的中文转码并且在后台action转回中文。
[/color]
body += "Content-Type: "+file.type+"\r\n\r\n";
body += file.getAsBinary() + "\r\n";
body += "--" + BOUNDARY + "--\r\n";
xhr.sendAsBinary(body);