Problem with POST method in Netscape7

Posted on 2003-03-27
Medium Priority
Last Modified: 2013-12-25

Sorry can somebody help me with this..
I am trying to upload a file to the server. THis is the html page and then i am calling a cgi script. Actually this works well in IE 6 but it gives problem in Netscape7. Here is the code. After i click the Upload File button it keeps going and i have some print statements in cgi which don;t get executed. It does not show anything and keeps running.
<title> Upload File </title>


<form name=upform method=POST action="upload.cgi" enctype="multipart/form-data">
<B>Select file:</B>
<input type=file name=uploadfile>
<input type="submit" value=" Upload File ">
<input type=button name="Cancel" value="Cancel" onclick="javascript:window.close()">


Question by:reenadpatel
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 3
  • 3
  • 2
LVL 48

Expert Comment

ID: 8221108
What are the contents of upload.cgi?

Expert Comment

ID: 8224842
Hi reenadpatel
I found no error with your HTML file. Could you please post your upload.cgi's source?

Author Comment

ID: 8224889

This is the code for upload.cgi


# environment variables
$request_method = $ENV{'REQUEST_METHOD'};
$rmtuser = $ENV{'REMOTE_USER'};  

# HTTP Content Header
print("Content-type: text/html\n\n");
print ("<html>\n");
print ("<title>Uploading File</title>\n");
print ("<head>\n");

print "$request_method\n";
print "$rmtuser\n";

#check request method
if($request_method eq "POST")  # POST method start
     @inx = <STDIN>;    
     @filetest = <STDIN>;
     $str = @inx[1];
   $str1 = reverse $str;
    $filename1 = "";
    $currchar = "";
    $offset = 3;
    while ($currchar !~ /\\/) {
    $currchar = substr($str1, $offset, 1);
    if ($currchar !~ /\\/) {
    $filename1 = "$filename1$currchar";
    $filename2 = reverse $filename1;
    $in = join("",@inx);
    $in = substr($in,0,length($in) - 2);;
($in,$out) = split /Content-Disposition/, $in , 2;
($in,$out) = split /\-----------------------------/, $in , 2;
    print "$filename2\n";
    open(ff,">$rmtuser\/$filename2") or die "Could not open file";
    print ff $in;
#    print $in;
    system ("chmod 777 $rmtuser\/$filename2");
#    print ("Uploaded file ".$filename2);
print ("<script language=\"javascript\">\n");
print ("alert(\"File Uploaded\")\;\n");
print ("self.close()\;\n");
print ("<\/script>\n");
print ("<\/head>\n");
print ("<\/html>\n");
#exit main script
exit 0;

When i click on Upload File in Netscape 7 then it keeps running but then i cannot see the print statements which i have give initially in the CGI executed.

Pl. help.

Get 15 Days FREE Full-Featured Trial

Benefit from a mission critical IT monitoring with Monitis Premium or get it FREE for your entry level monitoring needs.
-Over 200,000 users
-More than 300,000 websites monitored
-Used in 197 countries
-Recommended by 98% of users


Expert Comment

ID: 8225111
Hi reenadpatel,
When upload ding via CGI, the web server will cache all POSTed data then execute your script. Thus your script won't run at all untill all data has been sent to the server. Therefor your script must wait untill the file is completely uploaded. If you're uploading a very large file, you have to wait for a long time. Whtn you testes, did you use the same file for IE and Netscape?

Next checking point: you try to stop your script just right after:
print "$request_method\n";
print "$rmtuser\n";
to check if Netscape send the varable $ENV{'REMOTE_USER'} correctly! (try to upload a very small file to test this!)

Moreover, some environmental varables may be vary between browsers. You may use this "standard" technique to upload file:
my $req = new CGI();
my $filein = $req->param('uploadfile');
if ($filein =~ /([^\/\\]+)$/) {
#because some browsers set filename=c:\fullpath\filename.ext
#some others just send filename.ext
#we should check this to get the actual filename
     $filename = $1;

#convert filename to lower case if you wish
$filename = lc($filename);

open(FILE, ">fileout.ext");
while (my $bytesread = read($filein, my $buffer, 4096)) {
     print FILE $buffer;

The problem with your scripts is that IE and Netscape sent filename in different ways which caused your script trapped into a infinitive loop!

Hope this help.

Author Comment

ID: 8226046

Thanks for the reply. But I do not have any modules installed in my Perl installation.

So I cannot use new CGI. I want to use STDIN to do this..Can u suggest me how to do that?


Expert Comment

ID: 8226078
Hi reenadpatel,

CGI module is a standard module of Perl. It's so strange that your server doesn't have the CGI module installed! Please check this with your server's admin. A web server what supports Perl *must* have CGI module installed!
(or you may ask the server's admin if you can install it by yourself).

Hope this help.
LVL 48

Accepted Solution

Tintin earned 120 total points
ID: 8229179
If you find your server doesn't have CGI module installed, then get rid of yoru service provider as they are not earning their money.

Anyway, this is how I would rewrite it like:

use strict;
my $q = new CGI;
my $rmtuser = $ENV{'REMOTE_USER'};  

my $file = $q->param('uploadfile');
my $fh = $q->upload('uploadfile');

print $q->header;

open FILE, ">$rmtuser/$file" or die "Can not write to $rmtuser/$file $!\n";
binmode FILE;
print FILE <$fh>;
close FILE;

if (-z $rmtuser/$file) {
  print "<h1>Upload failed</h1>\n";
  print "<h1>Upload succeeded</h1>\n";


Author Comment

ID: 8240632
Thanks..it did work..it was really helpful.


Featured Post

Free Tool: Subnet Calculator

The subnet calculator helps you design networks by taking an IP address and network mask and returning information such as network, broadcast address, and host range.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Recently I have been answering a lot of questions like this in IT forums that I frequent. The question posed is usually something along the lines of "We have software X installed and need to uninstall it for reason Y" or some other variant of the sa…
Active Directory replication delay is the cause to many problems.  Here is a super easy script to force Active Directory replication to all sites with by using an elevated PowerShell command prompt, and a tool to verify your changes.
The viewer will learn how to look for a specific file type in a local or remote server directory using PHP.
In this fifth video of the Xpdf series, we discuss and demonstrate the PDFdetach utility, which is able to list and, more importantly, extract attachments that are embedded in PDF files. It does this via a command line interface, making it suitable …
Suggested Courses

770 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question