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
Expand|Select|Wrap|Line Numbers
- #!/usr/bin/perl
- print "content-type:text/html \n\n";
- print <<html_part;
- <html>
- <head>
- <script>
- function validate() {
- if(document.test.file.value=="") {
- alert("file name cannot be empty");
- return;
- }
- document.test.submit(true);
- }
- </script>
- </head>
- <body>
- <FORM name="test" ENCTYPE="multipart/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_form" onclick="validate()">
- </FORM>
- </body>
- </html>
- html_part
Expand|Select|Wrap|Line Numbers
- #!/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";
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...