Php code to asp.net (C #)

Source: Internet
Author: User
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

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

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.