php调用命令实现文档转换,分别在系统:Ubuntu和win10下-庆云php-

{site_name}

{site_name}

🌜 搜索

php调用命令实现文档转换,分别在系统:Ubuntu和win10下

▥ 𝄐 0
2021年验证的 系统:win10

php调用命令实现文档转换:这里特别注意下 exec 涵数 是否被系统禁用了。

$retval = 1;
// exec() might be disabled
$cmd = 'start soffice --convert-to pdf  D:/aaa/bbb.docx --outdir D:/aaa';
if (function_exists('exec')){
    @exec($cmd, $output, $retval);
}

// Did it work?
if ($retval > 0){
    exit('process_failed');
}
echo 'success';
  系统:Ubuntu,

php调用命令实现文档转换:这里特别注意下 exec 涵数 是否被系统禁用了。

<?php
$retval = 1;
// exec() might be disabled
$cmd = 'export HOME=/tmp/&&/usr/bin/libreoffice --headless --convert-to pdf /www/wwwroot/test/20210327.docx --outdir ./';

if (function_exists('exec')){
@exec($cmd, $output, $retval);
echo "===";
}
// Did it work?
if ($retval > 0){
exit('process_failed');
}