【问题标题】:exec pdfimages in PHP在 PHP 中执行 pdfimages
【发布时间】:2015-09-20 10:44:33
【问题描述】:

我通过 VPS (CentOS) 拥有完全的 root 访问权限。

在 Unix shell 中,我可以使用以下命令提取图像:

pdfimages -j xyz.pdf images

但是我无法通过 PHP 执行命令

exec ("pdfimages -j xyz.pdf images");

xpdf 已安装。我还检查了 // Exec 函数是否存在; // 执行未禁用; // 安全模式未开启.. 使用以下代码:

$exec_enabled =
   function_exists('exec') &&
   !in_array('exec', array_map('trim', explode(', ', ini_get('disable_functions')))) &&
   strtolower(ini_get('safe_mode')) != 1;
if($exec_enabled) { echo "enabled"; }

以下内容正在正确执行:

exec("ls -1 *.php", $output);

  foreach ($output as &$tmp){
     echo "<a href=\"$tmp\">$tmp</a><br>";
  }

我做错了什么?问题出在哪里?

【问题讨论】:

  • 以下代码:system('pdfimages -j xyz.pdf images 2>&1');给出以下输出“sh:pdfimages:找不到命令”

标签: php exec


【解决方案1】:

您需要像下面这样指定路径,这会将每个图像保存在您的 PDF 文件夹中。

'image' 只是文件名..

$path = 'path/to/your/folder/';

$pdf = $path.'xyz.pdf';

$command = 'pdfimages -j '.$pdf.' '.$path.'image';

exec($command);

【讨论】:

    猜你喜欢
    • 2014-03-28
    • 2011-02-11
    • 2023-03-20
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2023-03-21
    • 2015-09-30
    相关资源
    最近更新 更多