且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

Php exec命令在Windows上不工作,在命令行上工作

更新时间:2023-02-22 11:50:38

如果您的命令如下:

exec("pstill -F a4 -2 -c -c -c -c -g -i -t -K -d 700 -a 4 -m XimgAsCMYK -m Xspot -m Xoverprint -o D:\\outputfile.pdf D:\\input.jpg");

PHP转义反斜杠,因此到达shell的命令是 .. 。D:\outputfile.pdf D:\input.jpg 。您必须双重转义反斜杠:一次用于PHP,一次用于shell。

PHP escapes the backslashes, so the command that reaches the shell is ... D:\outputfile.pdf D:\input.jpg. You have to double-escape the backslashes: once for PHP and once for the shell.

exec("pstill -F a4 -2 -c -c -c -c -g -i -t -K -d 700 -a 4 -m XimgAsCMYK -m Xspot -m Xoverprint -o D:\\\\outputfile.pdf D:\\\\input.jpg");