do you need to do the "binmode()" command on the file handle of the file you are writing perhaps e.g
 
open (TESTFILE,">$SAVE_DIRECTORY\\try2.gif");
binmode(TESTFILE)
 
I haven't tried this out but it's just a thought.
 
Bill Stennett
-----Original Message-----
From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED]]On Behalf Of Shariman Azeze
Sent: Thursday, June 28, 2001 9:04 AM
To: [EMAIL PROTECTED]
Subject: Binary File Upload Problem

Hello,

I'm trying to create a File Upload script which recieve the file via HTML form. However, when ever the file is a binary file (i.e. image, compiled script) the upload will always produced a corrupted file.

FYI, I'm using ActivePerl Build 519 and running the script on a WinNT Server. The sample script that I'm using is as shown below:
 

    # Configurable Option
    $SAVE_DIRECTORY = "d:\\InetPub\\ftproot\\Temporary";   # Define where uploaded file should go (temp. directory)

    # Processing Info. Recieved from the Form
    $| = 1;
    chop $SAVE_DIRECTORY if ($SAVE_DIRECTORY =~ /\/$/);
    use CGI qw(:standard);       # Uses CGI library to process the info
    $query = new CGI;

    $run_file = $query->param(run_file);

    binmode($run_file);
    binmode(STDOUT);

    open (TESTFILE,">$SAVE_DIRECTORY\\try2.gif");
    while ($Bytes = read($run_file,$Buffer,1024))
     {
     $BytesRead += $Bytes;
     print TESTFILE $Buffer;
     }
    close(TESTFILE);
    exit;

Can someone share with me a working example of file upload script using ActivePerl and run on a WinNT environment?

Thanks in advance...

-SHARIMAN AZEZE-
[EMAIL PROTECTED]

Reply via email to