当前位置:Gxlcms > PHP教程 > php代码转换成asp.net(C#)

php代码转换成asp.net(C#)

时间:2021-07-01 10:21:17 帮助过:104人阅读

phpasp.netc#

php 代码转成 asp.net (C#)
1,简单文件上传
$uploadFileName=$_FILES['Filedata']['name'];
$uploadFile=$_FILES['Filedata']['tmp_name'];
if(is_uploaded_file($uploadFile))
{
$pos=strrpos($uploadFileName,'.');
$len=strlen($uploadFileName);
$extendType=substr($uploadFileName,$pos,$len);
$localFileName=date("Ymdhis").$extendType;

$localFile="wbUpload//".$localFileName;

if(move_uploaded_file($uploadFile,$localFile))
{

}
else
{
echo "upload failed";
}
}
?>

2,ppt文件上传并处理
$uploadFileName=$_FILES['Filedata']['name'];
$uploadFile=$_FILES['Filedata']['tmp_name'];
$pos=strrpos($uploadFileName,'.');
$len=strlen($uploadFileName);
$localFormat=substr($uploadFileName,$pos+1,$len);
if($localFormat!="php"&&$localFormat!="php3"&&$localFormat!="exe"&&$localFormat!="bat"&&is_uploaded_file($uploadFile))
{
$pos=strrpos($uploadFileName,'.');
$len=strlen($uploadFileName);
$extendType=substr($uploadFileName,$pos,$len);
$localFileName=$_GET['fileName'];
$localFile="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");
//转换
$ppt = new COM("powerpoint.application") or die("Unable to instantiate PowerPoint");
$ppt->Visible=true;
$ppt->Presentations->Open(realpath($localFile));
$pptCount=$ppt->activePresentation->Slides->Count;
$ppt->activePresentation->Export(realPath("./pptUpload")."//".$folder,"JPG",640,480);
$sql="insert into zl_ppt (name,folder,roomID,totalFrame,create_date) values ('{$uploadFileName}','{$folder}','{$_GET['roomID']}',{$pptCount},'{$create_date}')";
if(!$rs=$db->sql_query($sql))
{
echo "insert error";
}
$ppt->Quit();
$path2='.\pptUpload\'.$folder."\";
$handle=opendir($path2);
while ($file = readdir($handle)) {
if(!is_dir($file))
{
$len=strlen($file);
$newName=substr($file,6,$len);
rename($path2.$file,$path2.$newName);
}
}
closedir($handle);
}
else
{
echo "upload failed";
}
}
?>
转成 asp.net C# 可以实现相同功能的代码

人气教程排行