Enjoy unlimited access to all forum features for FREE! Optional upgrade available for extra perks.
Domain summit 2024

Problem Downloading .gz Via Ftp

Status
Not open for further replies.

fpforum

Level 8
Legacy Platinum Member
Joined
Nov 1, 2006
Messages
1,417
Reaction score
25
Hey everyone..I'm trying to download a file onto my server using FTP and PHP. The file I'm trying to download is a .GZ file and for some reason I keep getting the following error

first, my code
Code:
<?php
$conn_id = ftp_connect("hostname.com");
$login_result = ftp_login($conn_id, "username", "password");

if ((!$conn_id) || (!$login_result)) {
echo "FTP connection has failed!";
exit;
} else {
echo "Connected";
}

// get the file
$local = fopen("file.gz","w");
$result = ftp_fget($conn_id, $local,"home/username/public_html/folder/file.gz", FTP_BINARY);

// check upload status
if (!$result) {
echo "FTP download has failed!";
} else {
echo "Downloaded ";
}

// close the FTP stream
ftp_close($conn_id);
?>

next, the error
Code:
PHP Warning:  ftp_fget() [<a href='function.ftp-fget'>function.ftp-fget</a>]: Failed to open file. in /home/username/public_html/folder/file.php on line 14

Any idea what could be causing this? I see the file get created locally like it's trying to download - but it's always 0 bytes in size. I know some of you will say to just use the FTP link instead - but the server is locked to my IP so it must be downloaded locally..

Any help is appriciated!
 

Tia Wood

Web Developer
Legacy Exclusive Member
Joined
Jan 11, 2006
Messages
3,372
Reaction score
349
It sounds like either permissions or the path isn't correct.

Where are you running the script from?
 

katherine

Country hopper
Legacy Exclusive Member
Joined
Jul 9, 2005
Messages
8,428
Reaction score
1,290
Just a guess but:
Code:
$result = ftp_fget($conn_id, $local,"home/username/public_html/folder/file.gz", FTP_BINARY);
The / is missing before home ;) So you are attempting to write to a non-existent directory.
 
Status
Not open for further replies.

The Rule #1

Do not insult any other member. Be polite and do business. Thank you!

Sedo - it.com Premiums

IT.com

Premium Members

AucDom
UKBackorder
Be a Squirrel
MariaBuy

Our Mods' Businesses

UrlPick.com
URL Shortener

*the exceptional businesses of our esteemed moderators

Top Bottom