Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
183 views
in Technique[技术] by (71.8m points)

php - How to run below the code in cpanel

I have used below the code for converting PPT to IMG

<html>
<head>
<title>ShotDev.Com Tutorial</title>
</head>
<body>
<?php

    $ppApp = new COM("PowerPoint.Application");
    $ppApp->Visible = True;
    $strPath = realpath(basename(getenv($_SERVER["SCRIPT_NAME"]))); 
    $FileName = "MyPP";
    $ppName = "MySlides.ppt";


    //*** Open Document ***//
    $ppApp->Presentations->Open(realpath($ppName));

    //*** Save Document ***//
    $ppApp->ActivePresentation->SaveAs($strPath."/".$FileName,17);  //'*** 18=PNG, 19=BMP **'
    //$ppApp->ActivePresentation->SaveAs(realpath($FileName),17);

    $ppApp->Quit;
    $ppApp = null;
?>
PowerPoint Created to Folder <b><?php $FileName?></b>
</body>
</html>

its working only in http : //localhost but if I use this same code in my web-server(cpanel hosted location) location its showing following error.

Fatal error: Class 'COM' not found in /home/domainname/public_html/index.php on line 9

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Reply

0 votes
by (71.8m points)

Your web server is running Linux.

In order to install the PHP extension required to use the Component Object Model (php_com_dotnet this gives access to the COM Class) you need to be running Windows Server and you'll also need to have Microsoft PowerPoint installed on that Windows Server in order to manipulate the PPT in the way that you are trying to.


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...