hi all,
i have seen a program from web that is used to upload a file from particular directory..
My problem is that they have mentioned some file directory name in the program but when i am running the program, in the browser i am getting the directory is not valid..
In this program i have not involved to do any part,but i need to know about this code..
code for fileupload
[CODE=perl]
#!/usr/bin/perl
print "content-type:text/html \n\n";
print <<html_part;
<html>
<head>
<script>
function validate() {
if(document.tes t.file.value==" ") {
alert("file name cannot be empty");
return;
}
document.test.s ubmit(true);
}
</script>
</head>
<body>
<FORM name="test" ENCTYPE="multip art/form-data" ACTION="upload. cgi" METHOD="POST">
<p>
Please select a file to upload: <INPUT TYPE="FILE" NAME="file">
<p>
<INPUT TYPE="button" value="submit_f orm" onclick="valida te()">
</FORM>
</body>
</html>
html_part
[/CODE]
code for upload.cgi
[CODE=perl]
#!/usr/bin/perl
print "content-type:text/html \n\n";
use CGI;
my $cgi = new CGI;
my $file = $cgi->param('file' );
$file =~ m/^.*(\\|\/)(.*)/;
my $name = $2;
open(LOCAL, ">../sample/$name") or die $!;
while(<$file>) {
print LOCAL $_;
}
print $cgi->header();
print "$file has been successfully uploaded... thank you.\n";
[/CODE]
any help would be grateful..i can browse the file and attaching it, but it is not getting uploaded..
will u give me answer for this...
i have seen a program from web that is used to upload a file from particular directory..
My problem is that they have mentioned some file directory name in the program but when i am running the program, in the browser i am getting the directory is not valid..
In this program i have not involved to do any part,but i need to know about this code..
code for fileupload
[CODE=perl]
#!/usr/bin/perl
print "content-type:text/html \n\n";
print <<html_part;
<html>
<head>
<script>
function validate() {
if(document.tes t.file.value==" ") {
alert("file name cannot be empty");
return;
}
document.test.s ubmit(true);
}
</script>
</head>
<body>
<FORM name="test" ENCTYPE="multip art/form-data" ACTION="upload. cgi" METHOD="POST">
<p>
Please select a file to upload: <INPUT TYPE="FILE" NAME="file">
<p>
<INPUT TYPE="button" value="submit_f orm" onclick="valida te()">
</FORM>
</body>
</html>
html_part
[/CODE]
code for upload.cgi
[CODE=perl]
#!/usr/bin/perl
print "content-type:text/html \n\n";
use CGI;
my $cgi = new CGI;
my $file = $cgi->param('file' );
$file =~ m/^.*(\\|\/)(.*)/;
my $name = $2;
open(LOCAL, ">../sample/$name") or die $!;
while(<$file>) {
print LOCAL $_;
}
print $cgi->header();
print "$file has been successfully uploaded... thank you.\n";
[/CODE]
any help would be grateful..i can browse the file and attaching it, but it is not getting uploaded..
will u give me answer for this...
Comment