Hey!

If you want to transfer file through the browser, then you don't need an
FTP server.  
On submitting the upload form, the browser transmits the file to the web
server, and it is store in a temporary folder where you can ask for. You
need too  extra the value of the file field with param('field name') and
use it to ask the web server for the file. 

The whole thing may look like this:

# Get the directory and file name using param().
$location_and_file_name = $xyz->param('field name');

# Use regex to convert all Windows slashes "\" (e.g. "c:\blah\blah.txt")
to Linux "/" and # basename() will work ok.

$tmp = "$location_and_file_name";
$tmp =~s/\\/\//g;
$file_name = basename("$tmp");

open(DESTINATION, ">destination/$file_name") || die "Failed to open
file!"
    while (<$location_and_file_name >){
                chomp;
                print  DESTINATION $_;
        }
        close (DESTINATION);



This work well. I used it on my recent project.

Good luck






-----Ursprüngliche Nachricht-----
Von: Yupapa.com [mailto:[EMAIL PROTECTED] 
Gesendet: Donnerstag, 21. August 2003 00:10
An: [EMAIL PROTECTED]; [EMAIL PROTECTED]
Betreff: Re: File::Copy & CGI.pm

HiHi~

If you are transfering file from a local machine to a remote machine,
you do
not use File::Copy module to copy files.  File::Copy is used for copying
files locally.  You can use Net::FTP to transfer files from one machine
to
another.  And of course, you will need a FTP server for the machine
receiving the file.


Bye~
Yupapa
###############################
# Yupapa Web Hosting =^.^=
# Web Site - http://www.yupapa.com
# Email - [EMAIL PROTECTED]
###############################
"B. Fongo" <[EMAIL PROTECTED]>
???????:[EMAIL PROTECTED]
> 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")
> }
>
>
>
>
>





--
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to