Reputation: 167
So I am using the call php_com_dotnet in my code:
$word = new COM("word.application");
// Hide MS Word application window
$word->Visible = 0;
//Create new document
$word->Documents->Add();
// Define page margins
$word->Selection->PageSetup->LeftMargin = '2';
$word->Selection->PageSetup->RightMargin = '2';
// Define font settings
$word->Selection->Font->Name = 'Arial';
$word->Selection->Font->Size = 10;
// Add text
$word->Selection->TypeText("TEXT!");
// Save document
$filename = tempnam(sys_get_temp_dir(), "word");
$word->Documents[1]->SaveAs($filename);
// Close and quit
$word->quit();
unset($word);
header("Content-type: application/vnd.ms-word");
header("Content-Disposition: attachment;Filename=document_name.doc");
// Send file to browser
readfile($filename);
unlink($filename);
and I got his error:
Fatal error: Uncaught Error: Class 'COM' not found in /var/www/clients/client1/web1/web/nordin/save.php:6 Stack trace: #0 {main} thrown in /var/www/clients/client1/web1/web/nordin/save.php on line 6
so I looked around I added this to my php.ini file:
[COM_DOT_NET]
;extension=php_com_dotnet.dll
enable_dl = On
; extension_dir = "ext"
and it still doesn't work, what am I doing wrong? please help!
EDIT
my files are on a sftp server and I get error's like this:
ini_set('display_errors', 1);
ini_set('display_startup_errors', 1);
error_reporting(E_ALL);
Upvotes: 0
Views: 2881
Reputation: 219834
The semi-colon before the extension is a comment and means that extension is not enabled. To enable it you must remove that semi-colon:
;extension=php_com_dotnet.dll
becomes
extension=php_com_dotnet.dll
You may need to restart IIS after making this change.
Upvotes: 1