What are the Chinese characters deleted when SWFUpload is uploaded and saved? When uploading with SWFUpload, the file name is in English, but it is not displayed if it is Chinese. what is the problem? Where can I modify it?
First, the file I uploaded contains Chinese characters.
After uploading the file to the upload folder, the file name is (the date was added by myself). That is to say, only the words "biao" and "Chinese" are missing.
Display the complete file name and path in the database
Modify upload. php as follows:
// $ File_name = preg_replace ('/[^ '. $ valid_chars_regex. '] | \. + $/I ', "", basename ($ _ FILES [$ upload_name] ['name']);
$ File_name = basename ($ _ FILES [$ upload_name] ['name']);
$ File_name = iconv ("UTF-8", "GB2312", $ file_name );
I do not know how to solve this problem ~
Reply to discussion (solution)
$ Fn = 'Chinese file name .txt '; echo basename ($ fn );
. Txt
This is an old php problem: the Chinese path (file name) cannot be identified)
However:
1. the uploaded file name is not included in the path, and basename is not required.
2. if you use a Chinese file, there is a conflict with the default character set of the operating system.
3. if you do not rename a long-pass object, what if you encounter a file with the same name?
$ Fn = 'Chinese file name .txt '; echo basename ($ fn );
. Txt
This is an old php problem: the Chinese path (file name) cannot be identified)
However:
1. the uploaded file name is not included in the path, and basename is not required.
2. if you use a Chinese file, there is a conflict with the default character set of the operating system.
3. if you do not rename a long-pass object, what if you encounter a file with the same name?
Thank you, xuzuning moderator.
I searched for so many Chinese garbled characters and did not test basename (). I was negligent.
A file with the same name is intended to be followed by a string of time (accurate to seconds?
We do not recommend that you use a Chinese file name because the moderator has already explained the cause.
A file with the same name is intended to be followed by a string of time (accurate to seconds?
We recommend that you use time + random numbers to generate a file name for each file to be uploaded. do not use the original file name.
$ Oldname = 'myfile.xlsx'; $ newname = createFileName ($ oldname); echo $ newname; function createFileName ($ name) {// Get the suffix $ name = explode ('. ', $ name); $ ext = array_pop ($ name); // gets the number of microseconds $ r = explode ('. ', microtime (true); $ r = array_pop ($ r); // Generate newname $ newname = date ('ymdhis '). $ r. mt_rand (1000,9999 ). '. '. $ ext; return $ newname ;}
We do not recommend that you use a Chinese file name because the moderator has already explained the cause.
A file with the same name is intended to be followed by a string of time (accurate to seconds?
We recommend that you use time + random numbers to generate a file name for each file to be uploaded. do not use the original file name.
$ Oldname = 'myfile.xlsx'; $ newname = createFileName ($ oldname); echo $ newname; function createFileName ($ name) {// Get the suffix $ name = explode ('. ', $ name); $ ext = array_pop ($ name); // gets the number of microseconds $ r = explode ('. ', microtime (true); $ r = array_pop ($ r); // Generate newname $ newname = date ('ymdhis '). $ r. mt_rand (1000,9999 ). '. '. $ ext; return $ newname ;}
Thank you!