hai,

I have been trying about upload file downloaded from
www.perl.com.
have some questions about it:
 
1: The first question is i am unable to read from 
the file using the script given, How can I use a file
upload when I want the file content to be read.pl help
as the code is not getting executing after this
line---

while (my $bytesread = read($file, my $buffer, 1024))
---
in the script which i am using it is ######## in the
program to show till which line the code is executing.
 

-----------------------
code starts here
---------------------

#!c:/perl/bin/perl
print "content-type:text/plain\n\n";
use CGI; 
use CGI qw(:standard);

$basedir="/cgi-bin/pi";

$allowall = "yes";

#$filenotgood="no";

$donepage="thanks.html";

#"http://www.perlservices.com/";

#"thanks.html";

        my $req = new CGI; 
        my $file = $req->param("FILE1"); 
        if ($file ne "") 
        {
            $s=substr($file,3);
                print " the file naem is :$s";
                #my $fileName = $file; 
                my $fileName = $s; 
                print "file name to be copied is";
                print $fileName;
                #$fileName =raju.txt;
                #~ s!^.*(\\|\/)!!;
                $newmain = $fileName;
                if ($allowall ne "yes") 
                {
                        if (lc(substr($newmain,length($newmain) - 4,4)) ne
$theext)
                        {
                                $filenotgood = "yes";
                        }
                }
                if ($filenotgood ne "yes") 
                { 
                        print "hai";
                        open(OUTFILE,">$basedir/$fileName"); 
                        print "$basedir/$fileName<br>";
                        print "hai1";
##################
the problem is it not getting while executed
####################
while (my $bytesread = read($file, my $buffer, 1024)) 
                        { 
                                print "hai2";
                                print "bytesRead is :$bytesread";
                                print "buffer is :$buffer";
                                print OUTFILE $buffer; 
                        } 
                        close (OUTFILE); 
                }
        }

print "Content-type: text/plain\n";
print "Location:$donepage\n\n";





#########
html 
###########
<html>
<body>
<form method="get" action="/cgi-bin/gb.pl">
File 1: 
<input type="file" name="FILE1">
<br>
<input type="submit" value="Upload!">
</form>
</body>
</html>


regards
dayakar











__________________________________________________
Do You Yahoo!?
Send instant messages & get email alerts with Yahoo! Messenger.
http://im.yahoo.com/

Reply via email to