mrphobos Posted February 19, 2010 Share Posted February 19, 2010 Hello wise and merciful PHP elders. I'm attempting to setup/learn how to use FTP with php. I've written the following script. PHP Code: <?php $resource = ftp_connect('hidden'); $login = ftp_login($resource, 'hidden', 'hidden'); if($login){ printf("We are now connected"); }else{ printf("Connection faild"); } $list = ftp_rawlist($resource, '/idx', true); if (ftp_get($resource, '/var/www/downloads', '/IDX/features.txt.gz', FTP_BINARY)){ printf("...Files downloaded correctly"); }else{ printf("...Files not downloaded correctly"); } ?> In this script I'm attempting to download a file from the directory I know exists. The script logs in successfully and tells me "We are now connected...Files downloaded correctly", But there's no files in the directory and none appear to be downloaded. I told it to download a specific file that I know is inside there because I didn't know how to tell it to download all the files. When I change the downloads folder to a text file called download.txt the result is the same. My best guess is it has some thing to do with the files being .text.gz or perhaps it's some thing to do with the localhost downloads directory. I'm still looking into the problem but am not getting any where. I'm stuck and my wheels are spinning. Any help any of you could provide would be greatly appreciated. Thank you for your time. Link to comment https://forums.phpfreaks.com/topic/192673-php-ftp-basic-scripts/ Share on other sites More sharing options...
F00Baron Posted February 20, 2010 Share Posted February 20, 2010 Make sure you have write permissions to the directory. Try touching a file and see if it shows up. touch('/var/www/downloads/somethingunique.txt'); Link to comment https://forums.phpfreaks.com/topic/192673-php-ftp-basic-scripts/#findComment-1015344 Share on other sites More sharing options...
mrphobos Posted February 22, 2010 Author Share Posted February 22, 2010 Thank you for your reply. That apparently was the problem because it works now. I can download files one by one. The only issue that I can't seem to find solutions for by googleing it is how to select and download all the files in the folder without typing them each in. Thank you for your help. Link to comment https://forums.phpfreaks.com/topic/192673-php-ftp-basic-scripts/#findComment-1015855 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.