PDA

View Full Version : I'm looking for a script



D-Orange
June 8th, 2002, 11:26
that can download a file from an other server to the server the script is on. I believe it's possible.

nag
June 8th, 2002, 11:59
You have not mentioned that in which language do you want this script it may be in PHP,in Perl, in ASP or in JSP......:p
And also what do you meaning by "download" ????
I think you want to copy the file from one server to another server where script is running...If you want this try out this PHP script ..

<?php
/*Author-------Naveed
Description------Copies one file from a server to another
*/
$file = fopen("http://mysite.com/directory/firstfile.php", "r");
$my2=fopen("second.txt","w");
if (!$file) {
echo "<p>Unable to open remote file for reading.\n";
exit;
}
while(!feof($file)){
$naveed=fgets($file);
fputs($my2,$naveed);
}
echo "Successfull copying of file";
fclose ($file);
fclose($m2;
?>

Note that second.txt file would be written on thew server where script is running...
Also for binary files you should write -rb- and -wb-

D-Orange
June 8th, 2002, 13:42
PHP (mysql) would be nice. CGI is possible. I mainly want to use it for zip files. And yes want to copy a file from one server to another server.

YUPAPA
June 8th, 2002, 13:59
#!/usr/bin/perl
use LWP::UserAgent;
use LWP::Simple;
use strict;

my $file_want_to_get = q(http://www.abc.com/the_file.txt);
my $dir_to_save = q(the_file.txt);

my $result = mirror($file_want_to_get,$dir_to_save);

print "Content-Type: text/html\n\n";
print "Transload Result: $result\n";

__END__