usaravanan <> wrote:
> Hi
> 
> My html form is:
> 
> <FORM ACTION="http://localhost/virtual/webdav_single_file_upload.pl";
> METHOD="POST" ENCTYPE="multipart/form-data"> <SELECT
> name="Managers_select"> <OPTION SELECTED value="nothing">Select - -
> -</OPTION> <OPTION value="Vijay">Vijay</OPTION> <OPTION value="Mr.
> Naveen">Mr. Naveen</OPTION> </SELECT>   
> 
> File 1: <INPUT TYPE="file" NAME="file1" SIZE=40/> <INPUT
> TYPE="submit" NAME="Submit" VALUE="UPLOAD">  </FORM> 
> 
> Task: Trying to upload single file using webdav tool with if
> condition against OPTION SELECTED. 
> 
> My server perl code: webdav_single_file_upload.pl
> 

use strict;
use warnings;

I strongly advise adding the above to your script. It lets perl help you
to find bugs.

> use CGI;
> use CGI::Carp qw(fatalsToBrowser);
> use CGI qw(:cgi-lib :standard);

You only need one "use CGI" statement.

> use HTTP::DAV;
> 
> $d = new HTTP::DAV;
> 
> &ReadParse(%in);
> 
> $url = "http://www.emantras.com/webdav2/";;
> 
> $d->credentials( -user=>"vijay", -pass =>"****", -url =>$url);
> 
> $d->open( -url=>"$url" )  || die("Couldn't open $url: " .$d->message .
> "\n");
> 
>  $query = new CGI;
> 
>  $filename = $query->param("file1");

You are mixing the old fashioned cgi-lib and the more modern CGI
approach. It would be preferable, not to mention less confusing, to
stick to one of them. Preferably the CGI approach, as cgi-lib is old
hat.

> 
>  $filename =~s/\\/\/\//gi;

Why are you globally changing a single backslashes to two forward
slashes?
Also I don't think that either slash has a case which needs ignoring
(i.e. the i switch is redundant).

> 
>  if ( $in{"Managers_select"} = "Vijay")       ## I am checking
> condition 
> here with option selected. i.e if I select vijay it should go to put
>          method else it should terminate  { $d->put(-local =>
> "$filename", -url => $url);  } 

Here is your immediate problem. Your comment is wrong. What you are
using is an assignment operator, not a comparison operator. You should
probably be using the string comparison operator.

> 
>  else
>  {
>          print "Put Failed due to project manager code" . $d ->
> message . "\n";

This should probably be a "die", as you have included "use CGI::Carp
qw(fatalsToBrowser)". Print won't work very well without at least an
appropriate header.

>  }
> 
>   $d->unlock( -url => $url );
> 
>   print $query->header ( );
>  print <<END_HTML
> 
>  <HTML>
>  <HEAD>
>  <TITLE>Thanks!</TITLE>
>  </HEAD>
> 
> <body bgcolor="ffffcc">
> 
>  <P>file $filename has been uploaded!</P>
> 
>  </BODY>
>  </HTML>
> END_HTML
> ;
> 
> Additionally, Please explain how to call the option selected field
> value in perl. 

Not sure what you mean hear. If you mean to obtain the value from the
form, then the param function works just fine. For example, point your
form at the following script, which is essentially cut&paste from the
CGI module documentation (You have read the CGI module documentation?).

use strict;
use warnings;
use CGI ':standard';

print header;
print start_html("Test");
foreach my $key (param) {
    print "<strong>$key</strong> -> ";
    my @values = param($key);
    print join(", ",@values),"<br>\n";
}
print end_html();

HTH

-- 
Brian Raven 

______________________________________________________________________
This email has been scanned by the MessageLabs Email Security System.
For more information please visit http://www.messagelabs.com/email 
______________________________________________________________________

_______________________________________________
ActivePerl mailing list
ActivePerl@listserv.ActiveState.com
To unsubscribe: http://listserv.ActiveState.com/mailman/mysubs

Reply via email to