Problem: the PHP input user list is a csv file, which is displayed as garbled characters when opened in excel, and opened normally with notepad or ue. Check that the file encoding is UTF-8.
Solution:
Function down_file ($ filepath, $ filename)
{
If (! File_exists ($ filepath ))
{Www.2cto.com
Echo "backup error, download file no exist ";
Exit ();
}
Ob_end_clean ();
Header ('content-Type: application/download ');
Header ("Content-type: text/csv ");
Header ('content-Disposition: attachment; filename = "'. $ filename .'"');
Header ("Content-Encoding: binary ");
Header ("Content-Length:". filesize ($ filepath ));
Header ("Pragma: no-cache ");
Header ("Expires: 0 ");
Readfile ($ filepath );
$ E = ob_get_contents ();
Ob_end_clean ();
}
Using fnamepolic'usersdata.csv ';
$ Handle = fopen ($ fname, 'wb ');
$ StrUsersData = iconv ('utf-8', 'gb2312', $ strUsersData); // convert the Encoding
If (fwrite ($ handle, $ strUsersData) = false ){}
Fclose ($ handle );
Down_file(%fname,'555.csv ');