usaravanan <> wrote: > I need sample code for Put and GET property in WEBDAV tool with perl > script > > i.e ; PUT property => Uploads file from local system to remote server > with authentication > > GET property => vice versa of PUT; Downloads files from remote > server to local system; > > Both the above things are not working in the server. > > CODE: > > GET PROPERTY: > > <<<HTML FORM>>> > > <html> > <head> > <title>WebDAV Tool</title> > </head> > <body bgcolor="#ffffcc"> > <h3><u><font color="#BZZZZ"><center>Download Files / > Directory</center></font></u></h3> <FORM name="customer_admin" > ACTION="webdav_get.pl" METHOD="POST" > ENCTYPE="multipart/form-data"> > <table width="100%" align="center"> > <tr> > <td>Download Files/directory from url:</td> <td><SELECT name="url"> > <OPTION SELECTED > value="http://www.emantras.com/webdav2/">http://www.emantras.com/webdav2 /</OPTION> > </SELECT></td> <td><input type="text" name="download" > value=""/></td><td><input type="text" > name="local_folder" value=""/></td> > <td><input type="submit" name="webdav_get" value="Download"> </tr> > </table> </form> </body> </html> > ======================================================================== ====== > Perl script : webdav_get.pl > > use strict; > use warnings; > use CGI; > use CGI::Carp qw(fatalsToBrowser); > use HTTP::DAV; > > my $d = new HTTP::DAV; > > my $form = new CGI; > > my $url_emantras = "http://www.emantras.com/webdav2/"; > > $d->credentials( -user=>"****", -pass =>"*****", -url > =>$url_emantras); > > $d->open( -url=>"$url_emantras" ) || die("Couldn't open > $url_emantras: " .$d->message . "\n"); > > my $fold_file = $form->param("download"); > > my $localpath = $form->param("local_folder"); > > $d->get(-url=>"$url_emantras"."$fold_file", -to=>"$localpath"); > > $d->unlock(-url => $url_emantras); > > print $form->header ( ); > print <<END_HTML > > <HTML> > <HEAD> > <TITLE>Thanks!</TITLE> > </HEAD> > <body bgcolor="ffffcc"> > <P align="center">"$fold_file" is downloaded from $url_emantras to > $localpath.</P> </BODY> </HTML> END_HTML ; > ======================================================================== ================================= > > PUT PROPERTY > > <<HTML FORM>> > > <html> > <head> > <title>WebDAV Tool</title> > </head> > <body bgcolor="#ffffcc"> > <h3><u><font color="#BZZZZ"><center>Put File</center></font></u></h3> > <FORM name="customer_admin" ACTION="put_local.pl" METHOD="POST" > ENCTYPE="multipart/form-data"> > <table width="100%" align="center"> > <tr> > Put: <input type="file" name="File1" value=""/> <input type="submit" > name="sub" value="PUT "> </tr> </table> </form> </body> </html> > *************************************************** > > Perl script put_local.pl > > use strict; > use warnings; > use CGI; > use CGI::Carp qw(fatalsToBrowser); > use HTTP::DAV; > > my $browser = new CGI; > > my $d = new HTTP::DAV; > > my $url = "http://www.emantras.com/webdav2"; > > $d->credentials(-user=>"****", -pass=>"****", -url=>"$url"); > > $d->open(-url => "$url") || die ("Could not open $url"); > > my $file = $browser->param('File1'); > > $file =~s/\\/\//gi; > > $d->put(-local => "$file", -url=>"$url/sample/"); > $d->unlock( -url => $url ); > > print $browser->header(''); > print "<html>"; > print "<p>$file</p>"; > > > Both things are not working. Please workout and produce with positive > codings any how.
Simply saying "not working" doesn't really give us any clues. You have to tell us what is happening, and how that differes from what you expect. See http://www.catb.org/~esr/faqs/smart-questions.html for help on asking questions in for a such as this. I have never used HTTP::DAV but I notice a few things about your code. First, you should do more error checking. You should probably check all of your HTTP::DAV calls for success or failure. Also, there does not seem to be any validation of the input data, and allowing a remote user to specify a directory on your web server to download a file (in your get script) seems odd, and a potential security problem. 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 [email protected] To unsubscribe: http://listserv.ActiveState.com/mailman/mysubs
