I have no permission to copy a specified folder, so I zip this folder to another copyable place.
This folder contains a Chinese jpg file. 水都曲餚-主圖.jpg. How can I encode it?
pack.php
try {
$phar = new PharData('project2.tar');
$phar->buildFromDirectory(dirname(__FILE__) . '/_upload/htmlEdit/');
} catch (Exception $e) {
echo $e;
}
exception 'BadMethodCallException' with message 'Entry a- D .jpg cannot be created: phar error: invalid path " a- D .jpg" contains illegal character' in C:\\Servers\\www\\projects\\public\\m000257\\tk\\pack.php:8 Stack trace: #0 C:\\Servers\\www\\projects\\public\\m000257\\tk\\pack.php(8): PharData->buildFromDirectory('C:\\Servers\\www\\...') #1 {main}
Use urlencode($filename)
. All characters returned from urlencode are valid in filenames. After that you can urldecode()
the filenames back to UTF-8.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.