Gossamer Forum
Home : General : Perl Programming :

UPLOAD script : WinNT server ERROR with <FORM method='POST' enctype="multipart/form-data" action=...>

Quote Reply
UPLOAD script : WinNT server ERROR with <FORM method='POST' enctype="multipart/form-data" action=...>
Hello !

My upload script is working fine on Unix server but I got the error message below with WinNT server - I don't know why - please help

'c:\hosting\webhost4life\member\kwanny\cgi-bin\upload.cgi' script produced no output

This is my HTML code

<FORM method='POST' enctype="multipart/form-data" action="/cgi-bin/upload.cgi">
<INPUT type=file name=filename size=30>
<INPUT type=submit value="Upload Now">
</FORM>

As I said, this script worked very well on Unix. But it didn't with NT server - I've tried to modify method='GET' then I didn't get the error message but the script couldn't upload file to server.

I don't know much about winNT - I need your help !

Thanks a lot !

NewAge
Quote Reply
Re: [newage24] UPLOAD script : WinNT server ERROR with <FORM method='POST' enctype="multipart/form-data" action=...> In reply to
We'll need to see the perl code really as it's a perl code issue by the looks of it.
Quote Reply
Re: [Paul] UPLOAD script : WinNT server ERROR with <FORM method='POST' enctype="multipart/form-data" action=...> In reply to
Hi Paul !

Thanks for your respond ! Below is my script - It looks very simple but it works with Unix server - I don't know why I got error script produced no output with WinNT server.

file upload.html ---------------------

<HTML><HEAD>
<TITLE>Upload</TITLE>
<BODY>


<FORM method='POST' enctype="multipart/form-data" action="/cgi-bin/upload.cgi">
<INPUT type=file name=filename size=30><br><br>
<INPUT type=submit value="Upload Now">
</FORM>



</BODY></HTML>



file upload.cgi ----------------------

#!/usr/bin/perl

use CGI ;
$co=new CGI;
$file = $co -> param('filename') ;


$data_folder ="c:/hosting/webhost4life/member/kwanny/upload"; # (for sure this is a right path)

$num = time;
$rand=substr($num,2,5);
$ID="$rand$$";


$ext =".gif" if ($file =~m /\.gif/);
$ext =".jpg" if ($file =~m /\.jpg/);


open (FILE, ">$data_folder/$ID$ext");
@array = <$file>;
binmode(FILE);
foreach $array(@array) {
print FILE $array ;
}
close (FILE);


print "Control type: text/html\n\n";
print "Upload OK - Done";


Hope you can help me to get it works on WinNT server

Thanks so much !

NewA.
Quote Reply
Re: [newage24] UPLOAD script : WinNT server ERROR with <FORM method='POST' enctype="multipart/form-data" action=...> In reply to
If the file is not .jpg or .gif then your script will carry on and say the upload was successful. The file will be created with no extension - is that what you want?

You aren't error checking open() either incase the file can't be opened.

Try this re-write...

Code:
#!/usr/bin/perl
#=====================================
use CGI;
use strict;
main();
#=====================================

sub main {
#-----------------------------------------------------------
# Much nicer IMO.

my $IN = new CGI;
my $file = $IN->param('filename');
my $rnd = substr(time(), 2, 5) . $$;
my $datadir = 'c:/hosting/webhost4life/member/kwanny/upload';

# Make sure the extension is ok.
my ($ext) = substr($file, -3);
unless ($ext eq 'gif' or $ext eq 'jpg') {
# Return an error here.
}

# Upload the file.
open FH, ">$datadir/$rnd.$ext" or die "Can't open $datadir/$rnd.$ext: $!";
binmode FH;
print FH while (<$file>);
close FH;

# Looks ok.
print $IN->header();
print "Upload seems to have worked!";
}
Quote Reply
Re: [Paul] UPLOAD script : WinNT server ERROR with <FORM method='POST' enctype="multipart/form-data" action=...> In reply to
Hi Paul !

Do you have any idea why I got the Time Out message when I try to upload a big file (200MB) - What should I do now (I'm using MS Exchange Server) CGI Timeout

The specified CGI application exceeded the allowed time for processing. The server has deleted the process.

Thanks !
Quote Reply
Re: [newage24] UPLOAD script : WinNT server ERROR with <FORM method='POST' enctype="multipart/form-data" action=...> In reply to
I assume that you are using IIS as your web server, correct? Exchange is your email server. I would suggest increasing your timeout rate for the script.

Look at the following thread (in the GT forums) for more info:

http://www.gossamer-threads.com/..._Resolution_P240534/
========================================
Buh Bye!

Cheers,
Me