Php code to asp.net (C #) 1, simple file upload 2, pptfile Upload and processing & lt ;? Php $ u phpasp. netc #
Php code to asp.net (C #)
1. simple file Upload
$ 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. Upload and process pptfiles
$ 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 ");
// Conversion
$ 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 ";
}
}
?>
Convert to asp.net C # code that can implement the same function