>  기사  >  백엔드 개발  >  php 代码 转换成 asp.net (C#)

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

WBOY
WBOY원래의
2016-06-02 11:34:122582검색

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# 可以实现相同功能的代码

성명:
본 글의 내용은 네티즌들의 자발적인 기여로 작성되었으며, 저작권은 원저작자에게 있습니다. 본 사이트는 이에 상응하는 법적 책임을 지지 않습니다. 표절이나 침해가 의심되는 콘텐츠를 발견한 경우 admin@php.cn으로 문의하세요.