Jump to content


Photo

getfile ?


  • Please log in to reply
12 replies to this topic

#1 l3lade

l3lade
  • Members
  • PipPip
  • Member
  • 20 posts

Posted 15 March 2006 - 07:42 PM

how do i get a file from a remote server then save it localy. then i will cronjob it

#2 l3lade

l3lade
  • Members
  • PipPip
  • Member
  • 20 posts

Posted 18 March 2006 - 11:58 PM

please can someone tell me the code to get a remote file because i cant find it anywere then the code to save it somewere local

#3 ToonMariner

ToonMariner
  • Members
  • PipPipPip
  • Advanced Member
  • 3,342 posts
  • LocationNewcastle upon Tyne, UK

Posted 19 March 2006 - 12:03 AM

You can't write a script that sits on the server and forces a download to the client!!!! It would be a very dangerous world if that were common place.

The best you could do is e-mail the file as an attachment. At least you can do that in a cron job and still not have to worry about the destination machine being on or not.
follow me on twitter @PHPsycho

#4 l3lade

l3lade
  • Members
  • PipPip
  • Member
  • 20 posts

Posted 19 March 2006 - 12:28 AM

sorry you obiouasy dont understand what i want is.

1. get a file from a REMOTE server

2. save it to my local WEBSERVER

hope that helps you to help me :P

#5 kenrbnsn

kenrbnsn
  • Staff Alumni
  • Advanced Member
  • 8,235 posts
  • LocationHillsborough, NJ, USA

Posted 19 March 2006 - 01:33 AM

Do you have permission to get the file? Do you always know the file's name? Or at least part of the name? If so, look at the [a href=\"http://www.php.net/ftp\" target=\"_blank\"]ftp functions[/a].

Ken

#6 l3lade

l3lade
  • Members
  • PipPip
  • Member
  • 20 posts

Posted 19 March 2006 - 08:31 PM

ok now im getting problems with that. i get this error

Parse error: parse error, unexpected T_DNUMBER, expecting T_VARIABLE or '$' in /home/rmmsclan/public_html/main/mani_stats/ranks/index.php on line 8

useing this code (but with pass login and server ip)

<?php

// define some variables
$local_file = 'local.zip';
$server_file = 'server.zip';

// set up basic connection
$conn_id = ftp_connect($***.***.**.***);

// login with username and password
$login_result = ftp_login($conn_id, $******, $******);

// try to download $server_file and save to $local_file
if (ftp_get($conn_id, $local_file, $server_file, FTP_BINARY)) {
   echo "Successfully written to $local_file\n";
} else {
   echo "There was a problem\n";
}

// close the connection
ftp_close($conn_id);

?>


#7 hitman6003

hitman6003
  • Members
  • PipPipPip
  • Advanced Member
  • 1,807 posts

Posted 19 March 2006 - 08:39 PM

Why are you putting a $ in front of the ip on the following line?

$conn_id = ftp_connect($***.***.**.***);


#8 l3lade

l3lade
  • Members
  • PipPip
  • Member
  • 20 posts

Posted 19 March 2006 - 09:28 PM

i took it away and still have the error. i found out that if i take away the decimals i get this error

Warning: ftp_connect(): php_network_getaddresses: getaddrinfo failed: No address associated with hostname in /home/rmmsclan/public_html/main/mani_stats/ranks/index.php on line 8

Warning: ftp_login() expects parameter 1 to be resource, boolean given in /home/rmmsclan/public_html/main/mani_stats/ranks/index.php on line 11

Warning: ftp_get() expects parameter 1 to be resource, boolean given in /home/rmmsclan/public_html/main/mani_stats/ranks/index.php on line 14
There was a problem 
Warning: ftp_close() expects parameter 1 to be resource, boolean given in /home/rmmsclan/public_html/main/mani_stats/ranks/index.php on line 21

ps. this is a game server and the ip: 195.149.21.123 and this works in smart ftp and in the windows network thing but im not sure if its right for this :S

#9 Prismatic

Prismatic
  • Members
  • PipPipPip
  • Advanced Member
  • 503 posts
  • LocationSan Diego

Posted 20 March 2006 - 12:56 AM

$conn_id = ftp_connect("***.***.**.***");

the IP is a string, so treat it as such and put quotes around it.

#10 l3lade

l3lade
  • Members
  • PipPip
  • Member
  • 20 posts

Posted 20 March 2006 - 08:39 PM

ok i can feel that were clos now, but im getting this error

Warning: ftp_login(): Please tell me who you are in /home/rmmsclan/public_html/main/mani_stats/ranks/index.php on line 11

Warning: ftp_get(): Error opening mani_ranks.txt in /home/rmmsclan/public_html/main/mani_stats/ranks/index.php on line 14
There was a problem

could this be to do with the conn_id thing?

#11 l3lade

l3lade
  • Members
  • PipPip
  • Member
  • 20 posts

Posted 21 March 2006 - 04:38 PM

please help me im only new :(

#12 l3lade

l3lade
  • Members
  • PipPip
  • Member
  • 20 posts

Posted 22 March 2006 - 10:10 PM

ok so now it takes ages to load whitch at first i was happy about but once it had done i get this error

Warning: ftp_login() expects parameter 1 to be resource, boolean given in /home/rmmsclan/public_html/main/mani_stats/ranks/index.php on line 11

Warning: ftp_get() expects parameter 1 to be resource, boolean given in /home/rmmsclan/public_html/main/mani_stats/ranks/index.php on line 14
There was a problem 
Warning: ftp_close() expects parameter 1 to be resource, boolean given in /home/rmmsclan/public_html/main/mani_stats/ranks/index.php on line 21

... what im i doing now?

also it overwrites the old file with an empty one

#13 l3lade

l3lade
  • Members
  • PipPip
  • Member
  • 20 posts

Posted 24 March 2006 - 09:15 AM

any one know or am i being retarded?




0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users