php - exec doesn't execute command if path contains whitespaces -


when

exec("c:\\program files (x86)\\wkhtmltopdf\\wkhtmltopdf.exe --footer-center  http://bbc.co.uk c:\\test2.pdf",$output); 

nothing happens. file exists , the following line returns 1.

echo file_exists("c:\\program files (x86)\\wkhtmltopdf\\wkhtmltopdf.exe"); 

if change

 exec("d:\\wkhtmltopdf\\wkhtmltopdf.exe --footer-center  http://bbc.co.uk c:\\test2.pdf",$output); 

works fine. can fixed?

you need quote executable's path or escape white space. either:

exec("c:\\program^ files^ (x86)\\wkhtmltopdf\\wkhtmltopdf.exe --footer-center  http://bbc.co.uk c:\\test2.pdf",$output); 

or

exec("\"c:\\program files (x86)\\wkhtmltopdf\\wkhtmltopdf.exe\" --footer-center  http://bbc.co.uk c:\\test2.pdf",$output); 

will work.


Comments

Popular posts from this blog

Java sticky instances of class com.mysql.jdbc.Field aggregating -