The uploadify plug-in uses thinkphpajaxreturn to return unicode encoding?

Source: Internet
Author: User
{Code ...} I am using the upploadify plug-in to upload files. If the upload fails, an error message is returned, but $ this-& amp; gt; ajaxReturn ($ upload-& amp; gt; getError (); is the returned unicode code? U4e0au4f20u6587u4ef6u540eu7f00u4e0du5141u8bb8...
Public function fileup () {$ upload = new \ Think \ Upload (); // instantiate the upload class $ upload-> maxSize = 1024*1024*2; // set the attachment upload size $ upload-> exts = array ('jpg ', 'gif', 'png', 'jpeg ', 'zip', 'xls ', 'rar '); // set the attachment upload type $ upload-> rootPath = '. /Public/Uploads/'; // sets the root directory for uploading attachments $ upload-> savePath = ''; // sets the attachment upload (child) directory // upload File $ info = $ upload-> upload (); if (! $ Info) {// upload error message $ this-> ajaxReturn ($ upload-> getError ());} else {// foreach ($ info as $ file) {$ data ['filename'] = $ file ['name']; $ data ['filepath'] = 'uploads /'. $ file ['savepath']. $ file ['savename']; $ data ['filesize'] = $ file ['SIZE']; $ this-> ajaxReturn ($ data );}}}

I am using the upploadify plug-in to upload files. If the upload fails, an error message is returned,
But $ this-> ajaxReturn ($ upload-> getError (); is the returned unicode code?

\ U4e0a \ u4f20 \ u6587 \ u4ef6 \ u540e \ u7f00 \ u4e0d \ u5141 \ u8bb8

Why does it return unicode encoding? Why?
Can't Chinese characters be directly displayed?

Reply content:
Public function fileup () {$ upload = new \ Think \ Upload (); // instantiate the upload class $ upload-> maxSize = 1024*1024*2; // set the attachment upload size $ upload-> exts = array ('jpg ', 'gif', 'png', 'jpeg ', 'zip', 'xls ', 'rar '); // set the attachment upload type $ upload-> rootPath = '. /Public/Uploads/'; // sets the root directory for uploading attachments $ upload-> savePath = ''; // sets the attachment upload (child) directory // upload File $ info = $ upload-> upload (); if (! $ Info) {// upload error message $ this-> ajaxReturn ($ upload-> getError ());} else {// foreach ($ info as $ file) {$ data ['filename'] = $ file ['name']; $ data ['filepath'] = 'uploads /'. $ file ['savepath']. $ file ['savename']; $ data ['filesize'] = $ file ['SIZE']; $ this-> ajaxReturn ($ data );}}}

I am using the upploadify plug-in to upload files. If the upload fails, an error message is returned,
But $ this-> ajaxReturn ($ upload-> getError (); is the returned unicode code?

\ U4e0a \ u4f20 \ u6587 \ u4ef6 \ u540e \ u7f00 \ u4e0d \ u5141 \ u8bb8

Why does it return unicode encoding? Why?
Can't Chinese characters be directly displayed?

The ajaxreturn of thinkphp directly sends the json_encode of the Chinese character and then returns the output

You can urlencode the Chinese character before json_encode and then urldecode.

Or you can directly echo the information without json_encode, and the Chinese characters will not be encoded as unicode

Not always used$this->ajaxReturnCan be used directlyjson_encodeAnd add the second parameter.SON_UNESCAPED_UNICODE(This parameter should be supported by your version)
We also recommend that you use the same format as the data returned from failure.json
How can I writeforeachGo inside$this->ajaxReturn

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.