Rumah  >  Artikel  >  pembangunan bahagian belakang  >  php 代码 转换成 asp.net (C#)

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

WBOY
WBOYasal
2016-06-02 11:34:122582semak imbas

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

Kenyataan:
Kandungan artikel ini disumbangkan secara sukarela oleh netizen, dan hak cipta adalah milik pengarang asal. Laman web ini tidak memikul tanggungjawab undang-undang yang sepadan. Jika anda menemui sebarang kandungan yang disyaki plagiarisme atau pelanggaran, sila hubungi admin@php.cn