PHP Development
 
Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
User Name:
Password:
Remember me

The Shed is going Social! Join us on FaceBook and Twitter and chime in on the conversation.

Go Back   Dev Shed ForumsProgramming LanguagesPHP Development

Reply
Add This Thread To:
  Del.icio.us   Digg   Google   Spurl   Blink   Furl   Simpy   Y! MyWeb 
Thread Tools Search this Thread Rate Thread Display Modes
 
Unread Dev Shed Forums Sponsor:
  #1  
Old December 10th, 2012, 05:34 PM
BiggBrawler BiggBrawler is offline
Registered User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Dec 2012
Posts: 6 BiggBrawler User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 1 h 52 m 48 sec
Reputation Power: 0
Ftp_get doesn't download to computer

Hi all,

first time on here. I'm stuck and may just be understanding ftp_get () all together. Please help me.

I understand that ftp_get() should be able to download a file from the server (mine is on hostgator.com) to a folder on the local cpu. Can this be created in a chron job and done weekly without a person clicking or opening a webpage?

I seem to have it all set up to work EXCEPT I'm unsure how to set the file path to the local cpu folder. It saves it to the same folder that the .php file calling it is located instead of on my computer (as noted on many websites it will do but nobody states how to set it to your own cpu drive)?

Below is my code... Where is my thought process failing?

PHP Code:
<?php         $local_file "/Users/name/Driver_record.zip";//working from a mac currently
$server_file "/folder1/folder2/filename.csv";                 //-- Connection Settings 
$ftp_server "ip address";
$ftp_user_name "xxxx";
$ftp_user_pass "xxxx";

 
// set up basic connection
$conn_id ftp_connect($ftp_server);

// login with username and password

$login_result ftp_login($conn_id$ftp_user_name$ftp_user_pass);// try to download $server_file and save to local_file
ftp_pasv($conn_idTRUE);

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);
?>

Reply With Quote
  #2  
Old December 10th, 2012, 06:14 PM
rstoll rstoll is offline
Registered User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Dec 2012
Posts: 9 rstoll User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 2 h 3 m
Reputation Power: 0
The thing is, you write the file on the server and not on your computer (or are you executing the PHP file on your computer?). You would need to have acces to your computer from the server and your computer would have to be online everytime the cron job is executed on the server. Is that really what you want?

Reply With Quote
  #3  
Old December 10th, 2012, 06:46 PM
requinix's Avatar
requinix requinix is offline
Still alive
Click here for more information.
 
Join Date: Mar 2007
Location: Washington, USA
Posts: 12,696 requinix User rank is General 120th Grade (Above 100000 Reputation Level)requinix User rank is General 120th Grade (Above 100000 Reputation Level)requinix User rank is General 120th Grade (Above 100000 Reputation Level)requinix User rank is General 120th Grade (Above 100000 Reputation Level)requinix User rank is General 120th Grade (Above 100000 Reputation Level)requinix User rank is General 120th Grade (Above 100000 Reputation Level)requinix User rank is General 120th Grade (Above 100000 Reputation Level)requinix User rank is General 120th Grade (Above 100000 Reputation Level)requinix User rank is General 120th Grade (Above 100000 Reputation Level)requinix User rank is General 120th Grade (Above 100000 Reputation Level)requinix User rank is General 120th Grade (Above 100000 Reputation Level)requinix User rank is General 120th Grade (Above 100000 Reputation Level)requinix User rank is General 120th Grade (Above 100000 Reputation Level)requinix User rank is General 120th Grade (Above 100000 Reputation Level)requinix User rank is General 120th Grade (Above 100000 Reputation Level)requinix User rank is General 120th Grade (Above 100000 Reputation Level)  Folding Points: 417516 Folding Title: Super Ultimate Folder - Level 1Folding Points: 417516 Folding Title: Super Ultimate Folder - Level 1Folding Points: 417516 Folding Title: Super Ultimate Folder - Level 1Folding Points: 417516 Folding Title: Super Ultimate Folder - Level 1Folding Points: 417516 Folding Title: Super Ultimate Folder - Level 1Folding Points: 417516 Folding Title: Super Ultimate Folder - Level 1
Time spent in forums: 5 Months 1 Week 4 Days 4 h 42 m 26 sec
Reputation Power: 8969
Send a message via AIM to requinix Send a message via MSN to requinix Send a message via Yahoo to requinix Send a message via Google Talk to requinix
"How to set it to your own CPU drive"? What?

Your code is correct so far. Are you sure your script has permissions to write to /Users/name? Have you set error_reporting=E_ALL and display_errors=on in your php.ini, so that if there are any errors you'll see them?

Reply With Quote
  #4  
Old December 11th, 2012, 02:27 PM
BiggBrawler BiggBrawler is offline
Registered User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Dec 2012
Posts: 6 BiggBrawler User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 1 h 52 m 48 sec
Reputation Power: 0
Thanks for the questions,

The executing php file with php_get() would run as a cron job on the server containing the files to be downloaded. I want to download the file to my computer, say at 2am once a week from the hosting server.

I was not seeing how to set the path from the server ftp to my computer. Simply stating "C://folder/filename.csv" wouldn't state which computer in the world it would be downloading to. So i was thinking I would have to use an ip address as well.

I already have the file created on my server. I just wanted it downloaded to a folder on my computer without having to 'click', load a webpage, or any other action on my part.

I'm now looking into ftp_put() instead of 'getting' the file from the hosting server. I think i might have to PUT the file from one server folder to a folder on the second ftp server I have.

If this is the case; which server would be local and which would be remote? I'm guessing:
  • local_server = server writing the file to
  • remote_server = server reading the file

I hope this makes sense. If not, please let me know where my thought process is wrong.

Thanks,
BiggBrawler

Reply With Quote
  #5  
Old December 11th, 2012, 02:39 PM
gw1500se gw1500se is online now
Contributing User
Dev Shed Frequenter (2500 - 2999 posts)
 
Join Date: Jul 2003
Posts: 2,877 gw1500se User rank is Colonel (50000 - 60000 Reputation Level)gw1500se User rank is Colonel (50000 - 60000 Reputation Level)gw1500se User rank is Colonel (50000 - 60000 Reputation Level)gw1500se User rank is Colonel (50000 - 60000 Reputation Level)gw1500se User rank is Colonel (50000 - 60000 Reputation Level)gw1500se User rank is Colonel (50000 - 60000 Reputation Level)gw1500se User rank is Colonel (50000 - 60000 Reputation Level)gw1500se User rank is Colonel (50000 - 60000 Reputation Level)gw1500se User rank is Colonel (50000 - 60000 Reputation Level)gw1500se User rank is Colonel (50000 - 60000 Reputation Level)gw1500se User rank is Colonel (50000 - 60000 Reputation Level)gw1500se User rank is Colonel (50000 - 60000 Reputation Level) 
Time spent in forums: 1 Year 2 Weeks 8 h 52 m 47 sec
Reputation Power: 581
I think you are over complicating this. Why not share out the target directory on your computer and give your server permission to map it? Then simply copy to \\yourcomputer\yourshareddirectory\filename.
__________________
There are 10 kinds of people in the world. Those that understand binary and those that don't.

Reply With Quote
  #6  
Old December 11th, 2012, 03:23 PM
BiggBrawler BiggBrawler is offline
Registered User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Dec 2012
Posts: 6 BiggBrawler User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 1 h 52 m 48 sec
Reputation Power: 0
I.T. Dept. says to many holes in the firewall for that. Can not connect external linux server to internal file share.

Reply With Quote
  #7  
Old December 11th, 2012, 03:25 PM
ManiacDan's Avatar
ManiacDan ManiacDan is offline
Likely to be eaten by a grue.
Dev Shed God 10th Plane (9500 - 9999 posts)
 
Join Date: Oct 2006
Location: Pennsylvania, USA
Posts: 9,804 ManiacDan User rank is General 77th Grade (Above 100000 Reputation Level)ManiacDan User rank is General 77th Grade (Above 100000 Reputation Level)ManiacDan User rank is General 77th Grade (Above 100000 Reputation Level)ManiacDan User rank is General 77th Grade (Above 100000 Reputation Level)ManiacDan User rank is General 77th Grade (Above 100000 Reputation Level)ManiacDan User rank is General 77th Grade (Above 100000 Reputation Level)ManiacDan User rank is General 77th Grade (Above 100000 Reputation Level)ManiacDan User rank is General 77th Grade (Above 100000 Reputation Level)ManiacDan User rank is General 77th Grade (Above 100000 Reputation Level)ManiacDan User rank is General 77th Grade (Above 100000 Reputation Level)ManiacDan User rank is General 77th Grade (Above 100000 Reputation Level)ManiacDan User rank is General 77th Grade (Above 100000 Reputation Level)ManiacDan User rank is General 77th Grade (Above 100000 Reputation Level)ManiacDan User rank is General 77th Grade (Above 100000 Reputation Level)ManiacDan User rank is General 77th Grade (Above 100000 Reputation Level)ManiacDan User rank is General 77th Grade (Above 100000 Reputation Level)  Folding Points: 127430 Folding Title: Super Ultimate Folder - Level 1Folding Points: 127430 Folding Title: Super Ultimate Folder - Level 1Folding Points: 127430 Folding Title: Super Ultimate Folder - Level 1Folding Points: 127430 Folding Title: Super Ultimate Folder - Level 1Folding Points: 127430 Folding Title: Super Ultimate Folder - Level 1Folding Points: 127430 Folding Title: Super Ultimate Folder - Level 1
Time spent in forums: 2 Months 3 Weeks 17 h 28 m 32 sec
Reputation Power: 6112
Are you trying to download this file to the USER'S machine (the machine running chrome/firefox/whatever and viewing your site) or to YOUR machine (the machine running apache and PHP)?
__________________
HEY! YOU! Read the New User Guide and Forum Rules

"They that can give up essential liberty to obtain a little temporary safety deserve neither liberty nor safety." -Benjamin Franklin

"The greatest tragedy of this changing society is that people who never knew what it was like before will simply assume that this is the way things are supposed to be." -2600 Magazine, Fall 2002

Think we're being rude? Maybe you asked a bad question or you're a Help Vampire. Trying to argue intelligently? Please read this.

Reply With Quote
  #8  
Old December 11th, 2012, 03:35 PM
BiggBrawler BiggBrawler is offline
Registered User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Dec 2012
Posts: 6 BiggBrawler User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 1 h 52 m 48 sec
Reputation Power: 0
I'm using a php script on hostgator shared server and want to download a file using ftp to a startlogic shared server.

Reply With Quote
  #9  
Old December 11th, 2012, 03:45 PM
gw1500se gw1500se is online now
Contributing User
Dev Shed Frequenter (2500 - 2999 posts)
 
Join Date: Jul 2003
Posts: 2,877 gw1500se User rank is Colonel (50000 - 60000 Reputation Level)gw1500se User rank is Colonel (50000 - 60000 Reputation Level)gw1500se User rank is Colonel (50000 - 60000 Reputation Level)gw1500se User rank is Colonel (50000 - 60000 Reputation Level)gw1500se User rank is Colonel (50000 - 60000 Reputation Level)gw1500se User rank is Colonel (50000 - 60000 Reputation Level)gw1500se User rank is Colonel (50000 - 60000 Reputation Level)gw1500se User rank is Colonel (50000 - 60000 Reputation Level)gw1500se User rank is Colonel (50000 - 60000 Reputation Level)gw1500se User rank is Colonel (50000 - 60000 Reputation Level)gw1500se User rank is Colonel (50000 - 60000 Reputation Level)gw1500se User rank is Colonel (50000 - 60000 Reputation Level) 
Time spent in forums: 1 Year 2 Weeks 8 h 52 m 47 sec
Reputation Power: 581
If you have firewalls in the way, you probably will have to do a pull from the target rather than a push from the source.

Reply With Quote
  #10  
Old December 11th, 2012, 05:02 PM
BiggBrawler BiggBrawler is offline
Registered User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Dec 2012
Posts: 6 BiggBrawler User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 1 h 52 m 48 sec
Reputation Power: 0
Thumbs up

Quote:
Originally Posted by gw1500se
If you have firewalls in the way, you probably will have to do a pull from the target rather than a push from the source.


You saved me so much grief. You're correct.
I needed to pull (ftp_get) FROM the server with the file instead of trying to push (ftp_put) TO the server I wanted it on.

Thank you so much!

Reply With Quote
  #11  
Old December 13th, 2012, 03:46 AM
Northie's Avatar
Northie Northie is offline
Square Peg in a Round Hole
Click here for more information.
 
Join Date: Oct 2007
Location: North Yorkshire, UK
Posts: 3,419 Northie User rank is General 44th Grade (Above 100000 Reputation Level)Northie User rank is General 44th Grade (Above 100000 Reputation Level)Northie User rank is General 44th Grade (Above 100000 Reputation Level)Northie User rank is General 44th Grade (Above 100000 Reputation Level)Northie User rank is General 44th Grade (Above 100000 Reputation Level)Northie User rank is General 44th Grade (Above 100000 Reputation Level)Northie User rank is General 44th Grade (Above 100000 Reputation Level)Northie User rank is General 44th Grade (Above 100000 Reputation Level)Northie User rank is General 44th Grade (Above 100000 Reputation Level)Northie User rank is General 44th Grade (Above 100000 Reputation Level)Northie User rank is General 44th Grade (Above 100000 Reputation Level)Northie User rank is General 44th Grade (Above 100000 Reputation Level)Northie User rank is General 44th Grade (Above 100000 Reputation Level)Northie User rank is General 44th Grade (Above 100000 Reputation Level)Northie User rank is General 44th Grade (Above 100000 Reputation Level)Northie User rank is General 44th Grade (Above 100000 Reputation Level) 
Time spent in forums: 3 Weeks 5 Days 10 h 15 m 39 sec
Reputation Power: 3896
You CANNOT download files over FTP to your clients machine using the php functions you have there

FTP uses the client-server model; and the ftp_functions are for building/working with the client side of the model. Your website users will not be running an ftp server for you to 'upload' to

If you want to download files to YOUR own computer then get yourself a copy of filezilla or cyberduck and then look for ways to schedule that.

Also, please see this thread and, specifically, my reply
__________________
PHP OOPS! <?php DB::Execute(SQL::makeFrom($_GET))->fetchArray()->FormatWith(Template::getInstance('default'))->printHtml(); ?>

PDO vs mysql_* functions: Find a Migration Guide Here

[ Xeneco - T'interweb Development ] - [ Are you a Help Vampire? ] - [ Read The manual! ] - [ W3 methods - GET, POST, etc ] - [ Web Design Hell ]

Reply With Quote
Reply

Viewing: Dev Shed ForumsProgramming LanguagesPHP Development > Ftp_get doesn't download to computer

Developer Shed Advertisers and Affiliates



Thread Tools  Search this Thread 
Search this Thread:

Advanced Search
Display Modes  Rate This Thread 
Rate This Thread:


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
View Your Warnings | New Posts | Latest News | Latest Threads | Shoutbox
Forum Jump

Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
  
 


Powered by: vBulletin Version 3.0.5
Copyright ©2000 - 2013, Jelsoft Enterprises Ltd.

© 2003-2013 by Developer Shed. All rights reserved. DS Cluster - Follow our Sitemap