Home > Backend Development > PHP Tutorial > php执行unoconv如果目标文件中有中文,执行失败

php执行unoconv如果目标文件中有中文,执行失败

WBOY
Release: 2016-06-06 20:29:42
Original
1907 people have browsed it

shell脚本

<code>python /alidata/www/xxt/cus/unoconv --verbose -f pdf /alidata/www/xxt/kcfinder/upload/6a3f354b11cf2bac07188e42f97d8081/测试.pptx"</code>
Copy after login
Copy after login

php中执行这个脚本

<code>exec('conv2pft')</code>
Copy after login
Copy after login

在console中直接执行脚本,正常。但是,php中执行没反应。发现,只要目标文件的路径中包含中文就不行。为什么???

回复内容:

shell脚本

<code>python /alidata/www/xxt/cus/unoconv --verbose -f pdf /alidata/www/xxt/kcfinder/upload/6a3f354b11cf2bac07188e42f97d8081/测试.pptx"</code>
Copy after login
Copy after login

php中执行这个脚本

<code>exec('conv2pft')</code>
Copy after login
Copy after login

在console中直接执行脚本,正常。但是,php中执行没反应。发现,只要目标文件的路径中包含中文就不行。为什么???

是因为操作系统编码的问题。php都是utf-8,但是操作系统是GBK,所以出错。
解决办法是把文件名转码:

<code>$filename = iconv('GBK', 'UTF-8', $filename);</code>
Copy after login

可能是字符编码问题,你看看php文件的编码方式是不是UTF-8

Related labels:
php
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template