Jump to content

PHP FTP basic scripts


mrphobos

Recommended Posts

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

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.

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.