This is a recurring topic in stackoverflow, but finally I couldn't find any clear solution.
I'VE THIS PHP SCRIPT ON MY LOCAL XAMPP (OS X)
test.php
<?php exec('lpr -MyPrinter photos/image.jpg'); ?>
IT WORKS IF I CALL IT FROM TERMINAL
kurt$ php test.php
BUT IT DOES NOT WORK IF I CALL IT FROM BROWSER
http://localhost/mysite/test.php
Consider that my security requirements are very low, because I'll use this script locally only for personal purposes. Can you address me to the right solution?
Could have any number of reasons, but I suggest to look at the error message. The exec() function will not return it, but you can redirect error output to a temporary file:
<?php exec('lpr -MyPrinter photos/image.jpg 2> /tmp/error.txt'); ?>
Look into /tmp/error.txt after calling the script in the browser.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With