php 代碼 轉換成 asp.net (C#)

來源:互聯網
上載者:User
關鍵字 php asp.net c#
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# 可以實現相同功能的代碼

  • 相關文章

    聯繫我們

    該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

    如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

    A Free Trial That Lets You Build Big!

    Start building with 50+ products and up to 12 months usage for Elastic Compute Service

    • Sales Support

      1 on 1 presale consultation

    • After-Sales Support

      24/7 Technical Support 6 Free Tickets per Quarter Faster Response

    • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.