l3lade Posted March 15, 2006 Share Posted March 15, 2006 how do i get a file from a remote server then save it localy. then i will cronjob it Quote Link to comment https://forums.phpfreaks.com/topic/5059-getfile/ Share on other sites More sharing options...
l3lade Posted March 18, 2006 Author Share Posted March 18, 2006 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 Quote Link to comment https://forums.phpfreaks.com/topic/5059-getfile/#findComment-18678 Share on other sites More sharing options...
ToonMariner Posted March 19, 2006 Share Posted March 19, 2006 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. Quote Link to comment https://forums.phpfreaks.com/topic/5059-getfile/#findComment-18682 Share on other sites More sharing options...
l3lade Posted March 19, 2006 Author Share Posted March 19, 2006 sorry you obiouasy dont understand what i want is.1. get a file from a REMOTE server2. save it to my local WEBSERVER hope that helps you to help me :P Quote Link to comment https://forums.phpfreaks.com/topic/5059-getfile/#findComment-18689 Share on other sites More sharing options...
kenrbnsn Posted March 19, 2006 Share Posted March 19, 2006 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 Quote Link to comment https://forums.phpfreaks.com/topic/5059-getfile/#findComment-18700 Share on other sites More sharing options...
l3lade Posted March 19, 2006 Author Share Posted March 19, 2006 ok now im getting problems with that. i get this error[code]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[/code]useing this code (but with pass login and server ip)[code]<?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_fileif (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 connectionftp_close($conn_id);?>[/code] Quote Link to comment https://forums.phpfreaks.com/topic/5059-getfile/#findComment-18874 Share on other sites More sharing options...
hitman6003 Posted March 19, 2006 Share Posted March 19, 2006 Why are you putting a $ in front of the ip on the following line?[code]$conn_id = ftp_connect($***.***.**.***);[/code] Quote Link to comment https://forums.phpfreaks.com/topic/5059-getfile/#findComment-18879 Share on other sites More sharing options...
l3lade Posted March 19, 2006 Author Share Posted March 19, 2006 i took it away and still have the error. i found out that if i take away the decimals i get this error [code]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 8Warning: ftp_login() expects parameter 1 to be resource, boolean given in /home/rmmsclan/public_html/main/mani_stats/ranks/index.php on line 11Warning: ftp_get() expects parameter 1 to be resource, boolean given in /home/rmmsclan/public_html/main/mani_stats/ranks/index.php on line 14There 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[/code]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 Quote Link to comment https://forums.phpfreaks.com/topic/5059-getfile/#findComment-18895 Share on other sites More sharing options...
Prismatic Posted March 20, 2006 Share Posted March 20, 2006 [code]$conn_id = ftp_connect("***.***.**.***");[/code]the IP is a string, so treat it as such and put quotes around it. Quote Link to comment https://forums.phpfreaks.com/topic/5059-getfile/#findComment-18928 Share on other sites More sharing options...
l3lade Posted March 20, 2006 Author Share Posted March 20, 2006 ok i can feel that were clos now, but im getting this error [code]Warning: ftp_login(): Please tell me who you are in /home/rmmsclan/public_html/main/mani_stats/ranks/index.php on line 11Warning: ftp_get(): Error opening mani_ranks.txt in /home/rmmsclan/public_html/main/mani_stats/ranks/index.php on line 14There was a problem[/code]could this be to do with the conn_id thing? Quote Link to comment https://forums.phpfreaks.com/topic/5059-getfile/#findComment-19136 Share on other sites More sharing options...
l3lade Posted March 21, 2006 Author Share Posted March 21, 2006 please help me im only new :( Quote Link to comment https://forums.phpfreaks.com/topic/5059-getfile/#findComment-19379 Share on other sites More sharing options...
l3lade Posted March 22, 2006 Author Share Posted March 22, 2006 ok so now it takes ages to load whitch at first i was happy about but once it had done i get this error[code]Warning: ftp_login() expects parameter 1 to be resource, boolean given in /home/rmmsclan/public_html/main/mani_stats/ranks/index.php on line 11Warning: ftp_get() expects parameter 1 to be resource, boolean given in /home/rmmsclan/public_html/main/mani_stats/ranks/index.php on line 14There 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[/code]... what im i doing now?also it overwrites the old file with an empty one Quote Link to comment https://forums.phpfreaks.com/topic/5059-getfile/#findComment-19767 Share on other sites More sharing options...
l3lade Posted March 24, 2006 Author Share Posted March 24, 2006 any one know or am i being retarded? Quote Link to comment https://forums.phpfreaks.com/topic/5059-getfile/#findComment-20204 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.