PHP exec() command problem
On my php page
I have this exec function converting pdf to swf
exec('"C:\\Program Files\\SWFTools\\pdf2swf.exe" "C:\\Program Files\\xampp\\htdocs\\system\\logs\\reports\\temp\\sample.pdf" -o "C:\\Program Files\\xampp\\htdocs\\system\\logs\\reports\\temp\\sample.swf" -f -T 9 开发者_C百科-t -s storeallcharacters');
on my localhost it works but whenever I put that function on another server let's say http://192.168.0.2:8888/system/ it doesn't convert the pdf at all...
Please help me get through this...
thanks
PHP is server-side. exec()
only works with commands on your server. When using exec()
, imagine being physically on your server and typing these commands. I assume your problem is that you don't have the program C:\\Program Files\\SWFTools\\pdf2swf.exe
on your server and that the files aren't there either.
Ok I already resolved my problem here. for others to know what I've done;
here's my code
// First, I create a new .bat file using fopen
$ourFileName = "C:\\FILE\\PATH\\TO\\sample.bat";
$ourFileHandle = fopen($ourFileName, 'w') or die("can't open file");
// Then write the content in it with your pdf2swf.exe syntax to convert from PDF to SWF
fwrite($ourFileHandle, '"C:\\Program Files\\SWFTools\\pdf2swf.exe" "C:\\FILE\\PATH\\TO\\sample.pdf" -o "C:\\FILE\\PATH\\TO\\sample.swf" -f -T 9 -t -s storeallcharacters');
// Close the handle
fclose($ourFileHandle);
// After all above executed successfully, we now run the newly created .bat file using PHP exec() function.
exec('"C:\\FILE\\PATH\\TO\\sample.bat"');
I don't know if there are any other way to do this but this works for me
using Windows Server 2003 with Apache 2 and PHP 5.2
精彩评论