I'm trying to use exec() to convert a .doc to a .html using abiword but the output is garbled (strange characters) (it works when running the same command from the server itself). I was wondering if there was a security setting that I need to look into, or if maybe the document isn't fully uploaded before the conversion begins (If so, how do I make sure that it is fully uploaded first)
Sorry, I'm modifying some older code that is above my skill, but I would like to get this function to work.
Sorry, I'm modifying some older code that is above my skill, but I would like to get this function to work.
Code:
$this->_convertFileTypes = array(".doc" => "abiword --to={TARGET} {SOURCE}");
Code:
function convert()
{
GLOBAL $settings;
if (file_exists($settings->_contentDir . $this->_dir . "index.html"))
return true;
if (!in_array($this->_fileType, array_keys($settings->_convertFileTypes)))
return false;
$source = $settings->_contentDir . $this->_dir . $this->getFileName();
$target = $settings->_contentDir . $this->_dir . "index.html";
// $source = str_replace("/", "\\", $source);
// $target = str_replace("/", "\\", $target);
$command = $settings->_convertFileTypes[$this->_fileType];
$command = str_replace("{SOURCE}", "\"$source\"", $command);
$command = str_replace("{TARGET}", "$target", $command);
$output = array();
$res = 0;
exec($command, $output, $res);
$myFile = "/mydms/content/log/testFile.txt";
$fh = fopen($myFile, 'a') or die("can't open file");
fwrite($fh, $command);
fwrite($fh, $res);
fclose($fh);
if ($res != 0)
{
print (implode("\n", $output));
return false;
}
return true;
}