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

WBOY
Release: 2016-06-02 11:34:12
Original
2588 people have browsed it

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

Related labels:
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template