Garbled characters may appear when uploading Chinese files. #2628
-
When I upload an image and the file name is in Chinese, garbled characters appear on the webpage. How can I solve this problem? const form = new FormData();
form.append('file', fs.createReadStream(filePath), encodeURI(fileName)); However, I don’t know where to place these codes. Does anyone know? |
Beta Was this translation helpful? Give feedback.
Replies: 2 comments 4 replies
-
Hey @clhome, I'm looking into this now 🔎 |
Beta Was this translation helpful? Give feedback.
-
To fix this issue, add the following property to the upload: {
defParamCharset: 'utf-8',
}, Here is a little background as to why... Payload uses the express-fileupload package to manage uploads. By default, this package has You have full control over the Note: here is the |
Beta Was this translation helpful? Give feedback.
To fix this issue, add the following property to the
upload
object in yourpayload.config
:Here is a little background as to why...
Payload uses the express-fileupload package to manage uploads. By default, this package has
defParamCharset
set tolatin1
. However, we need a character set that supports Chinese i.e.utf-8
.You have full control over the
express-fileupload
options with Payload, simply pass any valid properties to the upload object in your basepayload.config
.Note: here is the
defParamCharset
definition fromexpress-fileupload
: