PHP调用windows的com组件问题

一大波程序猿 2014-09-27 03:00:51
我有个程序需要把一个ppt转换成单页的图片,我的电脑室server2008的32位系统的,公司服务器是server2008的64位系统的,在我电脑上能转换成功,到服务器上确一直失败,也按照网上说的改为交互式用户,也添加NETWORK SERVICE用户,还是不行,文件复制成功,文件夹和文件夹里改转换的图片确没有,office已装没有问题,求大神帮忙,本人渣渣
<?php
/*********************/
/* */
/* Dezend for PHP5 */
/* NWS */
/* Nulled.WS */
/* */
/*********************/

$debug = true;
header( "Content-Type:text/xml;charset=UTF-8" );
header( "Cache-Control: no-store, no-cache, must-revalidate" );
header( "Cache-Control: post-check=0, pre-check=0", false );
require_once( "../inc/inc.php" );


$uploadFileName = $_FILES['Filedata']['name'];
$uploadFile = $_FILES['Filedata']['tmp_name'];
$localFormat = getFileExt( $uploadFileName );
$is_allowed_upload = true;
$forbbidenFileType = array( "php", "sh", "exe", "bat" );
putlog( "1: ".api_get_path( SYS_PATH ));

foreach ( $forbbidenFileType as $value )
{
if ( strtolower( $localFormat ) == $value )
{
$is_allowed_upload = false;
break;
break;
}
}
if ( strtolower( $localFormat ) != "ppt" )
{
$is_allowed_upload = false;
}
if ( $is_allowed_upload && is_uploaded_file( $uploadFile ) )
{

$extendType = getFileExt( $uploadFileName );

$localFileName = trim( $_GET['fileName'] );
$localFile = api_get_path( SYS_PATH )."meeting/pptUpload/".$localFileName;

if ( move_uploaded_file( $uploadFile, $localFile ) )
{
$pos = strrpos( $localFileName, "." );
$len = strlen( $uploadFileName );
$folder = substr( $localFileName, 0, $pos );
$create_date = date( "Y-m-d h:i:s" );
if ( !( $ppt = new COM( "powerpoint.application" ) ) )
{
exit( "Unable to Open MSPowerPoint" );
}
putlog( "断点1 ".$localFile ." ..");
$ppt->Visible = true;
putlog( "断点2 " );
$ppt->Presentations->Open( realpath( $localFile ) );
putlog( "断点3 " );
$pptCount = $ppt->activePresentation->Slides->Count;
$export_folder = api_get_path( SYS_PATH )."meeting/pptUpload/".$folder;
if ( !file_exists( $export_folder ) )
{
mkdir( $export_folder, 511 );
}

$ppt->activePresentation->Export( $export_folder, "JPG", 640, 480 );
$ppt->Quit( );

$sql = "insert into attachment (file_name,local_file_name,meet_no,file_size,file_type,created_time,model_type) values ('".$uploadFileName."','".$folder."','". trim( $_GET['roomID'] )."','".$pptCount."','".$extendType."',NOW(),'PRESENTATION')";
$rs = api_sql_query( $sql, __FILE__, 61 );
if ( !$rs && $debug )
{ putlog("insert zlchat pptFile -".$uploadFileName." ERROR!");
error_log( "insert zlchat pptFile -".$uploadFileName." ERROR!", 0 );
}else
putlog($sql);
$path2 = api_get_path( SYS_PATH )."meeting/pptUpload/".$folder."/";
$handle = opendir( $path2 );
while ( $file = readdir( $handle ) )
{
if ( !is_dir( $file ) )
{
preg_match_all( "/(\\d+)\\.JPG$/", $file, $name_arr );
$newName = $name_arr[0][0];
rename( $path2.$file, $path2.$newName );
}
}
closedir( $handle );
}
else
{
if ( $debug )
{
error_log( "upload zlchat pptFile -".$uploadFileName." ERROR!", 0 );
}
}
}
?>
...全文
312 5 打赏 收藏 转发到动态 举报
写回复
用AI写文章
5 条回复
切换为时间正序
请发表友善的回复…
发表回复
xuzuning 2014-09-28
  • 打赏
  • 举报
回复
组件注册了吗? 您在 64 位系统中使用 32 位的 com ? 那么 powerpoint.dll 需设置成兼容方式,并放在 %%system32%% 目录中
一大波程序猿 2014-09-28
  • 打赏
  • 举报
回复
没有错误提示,只是有断点2,断点1,再加一个路径,我也不知道用户有没有权限,我是复制了别人的代码,但是在我本机上就能用呢
一大波程序猿 2014-09-28
  • 打赏
  • 举报
回复
引用 4 楼 xuzuning 的回复:
组件注册了吗?
您在 64 位系统中使用 32 位的 com ?
那么 powerpoint.dll 需设置成兼容方式,并放在 %%system32%% 目录中

您好,组件不是安装好就会注册吗,我确实是在64位系统中使用32位的com,我用到的office03只有32位的。
还有powerpoint.dll在什么位置,怎么设置兼容模式本人比较菜,求教
安装目录下没有那个dll文件啊
傲雪星枫 2014-09-27
  • 打赏
  • 举报
回复
new COM( "powerpoint.application" ) php用户在服务器有权限调用?
傲雪星枫 2014-09-27
  • 打赏
  • 举报
回复
有什么错误提示吗?

21,886

社区成员

发帖
与我相关
我的任务
社区描述
从PHP安装配置,PHP入门,PHP基础到PHP应用
社区管理员
  • 基础编程社区
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧