SMFHacks.com
Modifications/Themes => General SMF Forum => Topic started by: shuban on March 21, 2017, 05:49:30 pm
-
I'm trying to execute a program that converts documents into plain text.
http://silvercoders.com/en/products/doctotext/
I've tried contacting the developer, but offers no help. My test server is on my Windows PC:
I would like to run the program in PHP. Here's what I have so far
<?php
$location = 'C:\\xampp\\htdocs\\test_doc.docx';
$output = exec("C:\\doctotext\\doctotext.exe /c $location");
echo 'The output: '.$output;
?>
Could someone steer me in the right direction? There are absolutely no examples on the internet using this free, powerful program.
-
You have to make sure the webserver has permission to execute the program doctotext.exe
You should give Apache access to that whole folder.
I would do this as well
$location = '"C:\\xampp\\htdocs\\test_doc.docx"';
-
I'm using XAMPP. Not sure how to do what you recommended. I wish I could get someone to try this out on their server, really stuck.
-
Good news, I got it working on my Windows based server:
<?php
$file = 'C:\xampp\htdocs\SMF\sdsdssss.docx';
$content = exec( 'C:\xampp\htdocs\SMF\doctotext\doctotext.exe /c '. $file , $output );
echo 'output of the file after read by doctotex.exe: ' ;
echo nl2br("\n");
print_r( $output );
echo nl2br("\n");
$string = '';
foreach ( $output as $o ) {
$string .= $o;
}
echo nl2br("\n");
However, how would I get this to work on my Centos server? Obviously I'd have to download the Linux version of the software, but how do the codes change?
-
It would be a different path to binary file.
-
Please advice, I placed doctotext into:
/home/***/public_html/doctotext
and the file:
/home/***/public_html/downloads/test_doc.docx
-
That would do it.
You would need to check the file permissions on doctext maybe try giving it 777
-
That would do it.
You would need to check the file permissions on doctext maybe try giving it 777
On the folder or the file itself? Should I do it recursively so that everything inside gets 777?
$file = '/home/***/public_html/downloads/test_doc.docx';
$content = exec( '/home/***/public_html/doctotext/doctotext \c '. $file , $output );
This didn't work...
-
Make sure it is part of the same user group as apache/webserver
Also make sure the file has excute permissions.
The program for sure. Maybe the whole directory if it is saving information to that folder.
-
The owner and group is both root.
I tried making everything 777, didn't help.
How would I check logs for this? Do logs even exist?
-
You could see if $content contains anything that is returned.
-
I checked and it doesn't return anything unforunately
-
The command is wrong. The fact I'm using /c means it's incorrect.
-
Do you have any other suggestions?
I asked this on Stack overflow, and got this response: http://stackoverflow.com/questions/42967583/executing-a-linux-program-from-php/42970170?noredirect=1#comment73058411_42970170
I think I'm running out of ideas
-
Not really stackoverflow is a good place though those people who reply to questions are experts.