1

PHPでwkhtmltoimageを使用して画面を取得しようとしています。動作していませんが、デバッグする方法がわかりません。サーバー管理者に連絡したところ、exec許可されているとのことでした。これが私のディレクトリ構造です:

-index.php
-lib/
  -screenshot.php
  -wkhtmltoimage/
     -wkhtmltoimage-i386
     -wkhtmltoimage-amd64

のコードscreenshot.phpは次のとおりです。

function screenshot($url, $save_path, $zoom = 0.5, $width = 500)
{
    $zoom = escapeshellarg($zoom);
    $width = escapeshellarg($width);
    $url = escapeshellarg($url);
    $save_path = escapeshellarg($shell_path);

    print_r(scandir("lib/wkhtmltoimage"));

    $output = array();

    echo exec("./lib/wkhtmltoimage/wkhtmltoimage-i386 --enable-plugins --zoom $zoom --width $width $url test.png", $output);
    echo exec("lib/wkhtmltoimage/wkhtmltoimage-i386 --enable-plugins --zoom $zoom --width $width $url test.png", $output);
    echo exec("./wkhtmltoimage/wkhtmltoimage-i386 --enable-plugins --zoom $zoom --width $width $url test.png", $output);
    echo exec("wkhtmltoimage/wkhtmltoimage-i386 --enable-plugins --zoom $zoom --width $width $url test.png", $output);
    echo exec("./lib/wkhtmltoimage/wkhtmltoimage-amd64 --enable-plugins --zoom $zoom --width $width $url test.png", $output);
    echo exec("lib/wkhtmltoimage/wkhtmltoimage-amd64 --enable-plugins --zoom $zoom --width $width $url test.png", $output);
    echo exec("./wkhtmltoimage/wkhtmltoimage-amd64 --enable-plugins --zoom $zoom --width $width $url test.png", $output);
    echo exec("wkhtmltoimage/wkhtmltoimage-amd64 --enable-plugins --zoom $zoom --width $width $url test.png", $output);

    print_r($output);
    die();
}

index.php は、url "http://www.nasa.gov/" で関数のスクリーンショットを呼び出します。

これが私が得る出力です:

Array
(
    [0] => .
    [1] => ..
    [2] => wkhtmltoimage-amd64
    [3] => wkhtmltoimage-i386
)
Array
(
)

目に見えて、エラーがどこから来たのかさえわかりません。パスが間違っているか、入力が何らかの形で間違っている可能性がありますが、これらの要因について出力を取得する方法がわかりません。関数でさえ、配列を介して出力行を返していないようです。

どうすればこれをデバッグできますか? どこから始めればよいですか?ディレクトリやファイルの実行をチェックするための PHP 関数はありますか?

4

1 に答える 1

3

ばかげた間違いです。ルート パスを使用する必要がありました。(例/home/...)

また、Web 開発の時間の半分がパスの問題を解決するために無駄になっていると感じている人はいますか? うーん。

于 2011-06-20T03:14:33.093 に答える