Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6050113
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 23, 20262026-05-23T07:39:09+00:00 2026-05-23T07:39:09+00:00

I trying to get a file from an FTP server using ftp_get from PHP

  • 0

I trying to get a file from an FTP server using ftp_get from PHP 5.3.3 (linux build).
I can login, I can list the files, but the ftp_get command does not download the file.

Here is the code I’m using.

$ftp_user_name = DBUSER;
$ftp_user_pass = DBUSERPASS;
$ftp_server = HOST;
$local_file = "poutarde.odt";
$server_file = "poutarde.odt";

// set up a connection to ftp server
$conn_id = ftp_connect($ftp_server);

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

// turn passive mode on
ftp_pasv($conn_id, true);

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

The “poutarde.odt” file is at the root of the FTP.

I checked the FTP download from a client (filezilla) and everything works perfectly.
However, using ftp_get, I get nothing (except the echo “There was a problem”), no even a PHP error, it just fails.

Thank you for you help.

Reno

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-23T07:39:09+00:00Added an answer on May 23, 2026 at 7:39 am

    ftp_get expects a file handler, not a filename.

    $local_file = fopen("poutarde.odt",'w');
    //...
    if(ftp_get($conn_id, $local_file, $server_file, FTP_BINARY))
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am trying to download files from an ftp server using C# and ftpwebrequest.
I'm trying to get a directory listing of files on an ftp server using
I am trying to use ftps to upload file to our FTP server. Login
I'm trying to get the contents from another file with file_get_contents (don't ask why).
I'm trying to get a file with ant, using the get property. I'm running
I'm trying get values from a GridView using the following code: foreach (GridViewRow row
I have to download some files from an FTP server. Seems prosaic enough. However,
I get the following message back when trying to retrieve a file using TCPClient
Greetings I'm trying to get an xml file from a website which requires me
in my app i am trying to get an xml file from an URL.

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.