What are the Chinese characters deleted when SWFUpload is uploaded and saved?

Source: Internet
Author: User
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!

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.