B. Fongo wrote: > Hi, > > I've a small script intended for file transfer from a windows > machine to a remote linux server. To implement that, I decided to > use two module i.e File::Basename, File::Copy and CGI.pm. > > The File::Copy is working well locally, but it fails to copy files > to a remote machine through the Browser. I use CGI.pm to generate a > form where users could browser and select a file to be transferred. > The error message is always: "No such file or directory" though the > file or directory exist and permission is set 777. > > What may be the case? Any suggestion on how to transfer file to > remote location? > I'm not sure whether it will be applicable to use file handles and > use a loop to read the files from the source location and write > them to a destination folder. > > Thanks for any help > > > > ############################################## > #!/usr/bin/perl -w > > use strict; > use CGI qw/ :standard/; > my $cgi = new CGI; > > use File::Basename; > > if( param()){ > upload_file(param("upload_file")); > } else { > print_form(); > } > > > #### Subroutine to transfer file ########### > > sub upload_file{ > > my ($file, $file_destination, $file_name, $forwarded_value); > $original_src = $forwarded_value = $_[0]; > $file_destination = q(/data/Software_Pakete); > $forwarded_value =~ s/\\/\//g; > $file_name = basename("$forwarded_value"); > if (copy("$original_src","$file_destination/$file_name")){ > print_success() > } > else{ > print_error("$forwarded_value","$file_destination/$file _name") > }
You seem to have copied a small part of the CGI documentation, and copied it wrongly. If a browser returns input to the server from a form with a file input field, then param('field_name') will return a scalar which is useable as a standard filehandle. The CGI POD gives an example of such a field with a name of 'uploaded_file'. It looks like you're copying this with a name of 'upload_file' but it will only work with an input field with a matching name. A sight of your output HTML would help. Rob -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]