ASP/Perl to PHP Conversion

Discussion in 'PHP' started by cmc@savycat.com, Oct 9, 2004.

  1. #1
    Does anyone know how to convert either of these two scripts to PHP?

    ==========
    === ASP ===
    ==========

    <%

    base_folder = "c:\inetpub\wwwroot\"

    'no changes are required below this point.

    PostData = ""
    biData = Request.BinaryRead(Request.TotalBytes)
    if len(bidata) > 0 then
    image_info = Request.ServerVariables("HTTP_CONTENT_DISPOSITION")
    image_info_values = split(image_info, "=")
    image_name = replace(image_info_values(1), chr(34), "")

    For nIndex = 1 to LenB(biData)
    PostData = PostData & Chr(AscB(MidB(biData,nIndex,1)))
    Next

    Set lf = server.createObject("Scripting.FileSystemObject")
    Set SaveFile = lf.CreateTextFile(base_folder & image_name , True)
    SaveFile.Write(PostData)
    SaveFile.Close
    end if

    %>

    ===========
    === PERL ===
    ===========

    #!/usr/bin/perl -w

    print "Content-Type: text/plain\r\n\r\n";
    print "Upload OK\r\n";

    open UPLOADFILE, ">C:\\Temp\\upload.txt";
    foreach my $variable (keys %ENV) {
    print UPLOADFILE $variable, "->", $ENV{$variable}, "\n"; }
    my $length = $ENV{'CONTENT_LENGTH'};
    my $file_name = $ENV{'HTTP_CONTENT_DISPOSITION'};
    $file_name =~ s/^attachment; filename=\"(.*)\"$/$1/;

    print UPLOADFILE "length ", $length, "\n";
    print UPLOADFILE "name ", $file_name, "\n";
    open IMG_FILE, ">C:\\Temp\\$file_name";
    binmode(IMG_FILE);
    my $buffer;
    read(STDIN,$buffer, $length);
    print IMG_FILE $buffer;
    #chmod 0666, "C:\\Temp\\$file_name";
    close(IMG_FILE);
    close(UPLOADFILE);

    exit 0;
     
    cmc@savycat.com, Oct 9, 2004 IP
  2. seacaptdon

    seacaptdon Peon

    Messages:
    1
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #2
    Here is a website I found to do ASP to PHP conversions: http://www.design215.com/toolbox/translator/trans_login.php
    I used it and it seemed to work well.
     
    seacaptdon, Mar 9, 2005 IP