Article From:https://segmentfault.com/q/1010000011097292
Question:

ftpThe operating system is Linux, and PHP runs under win2008
In code, $server_file can not be downloaded into Chinese, so English files can be downloaded and asked for answers.

<?php
// Defining variable$local_file ='test1.gif';$server_file ='/20170909/113/ Han.Gif'; / / Chinese file error//$server_file ='/20170909/113/mmm.gif'; / / / English document can/ / connect FTP server$conn_id = ftp_connect ("xxx.xxx.xxx.xxx");/ / verify the login server$ftp_usEr_name = "XXX";$ftp_user_pass = "XXX";$login_result = ftp_login ($conn_id, $ftp_user_name, $ftp_us)Er_pass);Var_dump ($login_result);Ftp_pasv ($conn_id, true);/ / download fileVar_dump (ftp_get ($conn_id, $loc)Al_file, $server_file, FTP_BINARY));/ / close the FTP connectionFtp_close ($conn_id);>

Answer 0:

Brother, as long as the Chinese file is downloaded, you need to transcode the file name first and then download it.

iconv(‘UTF-8’, ‘GBK’, $server_file )

Leave a Reply

Your email address will not be published. Required fields are marked *